Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing a windows application in which the input is in marathi language. I have the code to insert data in sql server.
SQL
create database Test

create table marathi(Names nvarchar(22))
insert marathi SELECT N'नमस्कार'     ---- Right Query
insert marathi SELECT 'नमस्कार'         ---- Wrong Query
select *from marathi

just check once the above query in sql, you will understand it. If u write the query using N prefix then in sql it shows the data properly, but if don't use N prefix then it shows ??????? in sql server.
But now my problem is that I am trying to do same from my window application. I wrote the following code.
C#
SqlCommand slc = con.CreateCommand();            
slc.CommandText = "Insert into marathi values(@Names)"
slc.Parameters.Add("@Names", SqlDbType.NVarChar, 22);            
slc.Parameters["@Names"].Value = textBox1.Text;
slc.ExecuteNonQuery();

it is saved but not in unicode, normal alphabets can be seen.
How can I achieve this? Please Help....
Posted
Updated 14-Mar-15 7:33am
v3
Comments
[no name] 14-Mar-15 10:02am    
So what's the problem with your code? Does it throw an exception? Or does it simply not create a new row in the table? You might need to add a transaction.
Ank_ush 14-Mar-15 12:52pm    
In sql I tried the above query with prefix N then it shows the data as नमस्कार and without prefix N it shows ???????. I want to write the code of the Right one query in my program but I am facing problem, so how can I ?
[no name] 14-Mar-15 12:54pm    
And what is the problem that you are facing?
Ank_ush 14-Mar-15 12:59pm    
by writing the above c# code the value entered in windows form is not saved in unicode format in sql. in SQL server if I write this
insert marathi SELECT N'नमस्कार' then by using, select * from marathi it shows नमस्कार in sql server. This query I want to implement in c# code in windows application, but not getting, any help plzzz....
[no name] 14-Mar-15 13:07pm    
Is it not saved at all or not in Unicode?

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900