C# and SQL server problem

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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
 
Back
Top