C# and SQL server problem

G

Guest

Dear sirs:
I'm making an application using C# and i connect through
it to a database made by MSSQL server but i have a problem
when inserting or updating in the database in arabic that
each arabic letter is replaced by a question mark (?)
the code i'm using to insert is
oleDbDataAdapter1.InsertCommand.CommandText=" sql
Statement";
and to update is:
oleDbDataAdapter1.UpdateCommand.CommandText="sql
statement";
Note:
I successeded to insert and to update in english by that
code but the problem is in arabic
 
N

Nicholas Paldino [.NET/C# MVP]

Mostafa,

Is the column you are trying to enter data into an nvarchar or nchar
column? These columns can handle unicode characters, whereas the char and
varchar are ansi characters.

Also, you have to make sure your string is prefixed with n (e.g. n"my
string") to make sure it is interpreted as a unicode string.

Hope this helps.
 
H

Hans Kesting

mostafa atalla said:
Dear sirs:
I'm making an application using C# and i connect through
it to a database made by MSSQL server but i have a problem
when inserting or updating in the database in arabic that
each arabic letter is replaced by a question mark (?)
the code i'm using to insert is
oleDbDataAdapter1.InsertCommand.CommandText=" sql
Statement";
and to update is:
oleDbDataAdapter1.UpdateCommand.CommandText="sql
statement";
Note:
I successeded to insert and to update in english by that
code but the problem is in arabic

Are you specifying the values within the sql-string
(insert into names_table (name) values ('Hans') ) ?
If so, you might need to look at parameters.
For plain english you then avoid problems with names like O'Brien.
It might work with your arabic texts as well (if the columns
accept unicode strings, see the other replies)

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top