Click here to Skip to main content
15,666,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey Guys,

I've a Problem in saving arabic data to the database on the database online

but it works fine on the database on my pc

i am using with

the insert statment is a string query

string ssql = "insert into table (col1,col2,col3) values ('"+textbox1.text+"','"+textbox2.tex+"','"+textbox3.text+"')"

textbox2.text is the arabic data

any ideas???
What is the DataType of the columns in that Table ?
_ProgProg_ 25-May-13 3:19am    
nvarchar for the arabic data column
Then it should save. Can you give me one example of data what you are sending and what is getting saved for that data ?
_ProgProg_ 25-May-13 3:26am    
i am saving banks
if i entered البنك الاهلى
it saves it as ?????????????????????
and the grid view also shows it as ?????????????????
Can you debug and check what is the value of ssql ? Please post here and can you confirm if you are not doing anything to this string after making the query string.

there should be capital "N" without space before your arabic name in the string..and it works fine with me in marathi
string ssql = "insert into table (col1, col2, col3) values (N'" + textbox1.Text + "', N'" + textbox2.Text + "',N'" + textbox3.Text + "')"
Share this answer
_ProgProg_ 26-May-13 2:59am    
should this be in insert and update????
Basmeh Awad 26-May-13 3:15am    
yes you have to do while insert and update...
_ProgProg_ 26-May-13 3:29am    
thanks to you Basmeh Awad
Basmeh Awad 26-May-13 3:44am    
Please try like this...
string ssql = "insert into table (col1, col2, col3) values ('" + textbox1.Text + "', '" + "N" + textbox2.Text + "', '" + textbox3.Text + "')"

I assume that textbox2.Text is the Arabic data.
Share this answer
_ProgProg_ 25-May-13 4:27am    
okay i 've tried this but ther result was as follows:
N????? ??????
Ramesh Bhupalam 9-Apr-18 1:35am    
i am also facing like this problem.
please help.

By using a parametrized query you can eliminate the messy string concatenation and other problems associated with it and sql injection. It is also much easier to read and update in the future if you need to add another parameter.

cn.ConnectionString = @"ConnectionString";
SqlCommand com = new SqlCommand();
com.Connection = cn;
com.CommandType = CommandType.Text;

com.CommandText = "insert into Persons_info(perId, latinName, gender, dob, pob, phone, passport, curAdd, status) values (@perId, @latinName, @gender, @dob, @pob, @phone, @passport, @curAdd, @status)"
com.Parameters.Add(new SqlParameter("@perId", txtId.Text));
com.Parameters.Add(new SqlParameter("@latinName", txtLatinName.Text));
com.Parameters.Add(new SqlParameter("@gender", cbGender.Text));
com.Parameters.Add(new SqlParameter("@dob", dTPdob.Text));
com.Parameters.Add(new SqlParameter("@pob", txtPob.Text));
com.Parameters.Add(new SqlParameter("@phone", txtPhone.Text));
com.Parameters.Add(new SqlParameter("@passport", txtPassport.Text));
com.Parameters.Add(new SqlParameter("@curAdd", txtCurAdd.Text));
com.Parameters.Add(new SqlParameter("@status", cbStatus.Text));

MessageBox.Show("Saving is done!");
Share this answer
AntonyJoseph 20-Jun-15 9:39am    
Hi, In your procedure, you have not mentioned N' character.Could you please add in the right place.

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