Ankush

Ankush

  • NA
  • 267
  • 63.5k

How to insert unicode data in sql using c#

Mar 14 2015 6:52 AM
 I am developing a windows application in which the input is in marathi language. I have the code to insert data in sql server.
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.
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();
How can I achieve this? Please Help....

Answers (1)