after typing in arabic in form press insert button insert fields in db. characters turn strange question marks :"?????"
. doesn't happen numbers or english characters.
how type arabic , still have in db arabic, not "?????"
?
here code
sqlconnection cn = new sqlconnection(system.configuration.configurationmanager.connectionstrings["storeconnectionstring"].tostring()); public addbook() { initializecomponent(); } private void button1_click(object sender, eventargs e) { string x; cn.open(); sqlcommand cm = new sqlcommand("select count(*) storeitem", cn); int32 count = (int32)cm.executescalar(); x = count.tostring(); cn.close(); sqlcommand cmd = new sqlcommand("insert storeitem (id, title, writer, price, qun, date) values ('" + x + "','" + textbox1.text + "', '" + textbox2.text + "', '" + textbox3.text + "', '" + textbox4.text + "', '" + datetime.now.tostring("d/m/yyyy") + "')", cn); cn.open(); cmd.executenonquery(); cn.close(); textbox1.text = null; textbox2.text = null; textbox3.text = null; textbox4.text = null; this.close(); } private void button2_click(object sender, eventargs e) { this.close(); }
and
private void rsh() { sqldataadapter adap = new sqldataadapter("select * storeitem", cn); dataset ds = new dataset(); adap.fill(ds, "store"); datagridview1.datasource = ds.tables["store"]; datagridview1.columns[1].width = 200; datagridview1.columns[0].headercell.value = "#"; datagridview1.columns[1].headercell.value = "عنوان الكتاب"; datagridview1.columns[2].headercell.value = "الكاتب"; datagridview1.columns[3].headercell.value = "السعر"; datagridview1.columns[4].headercell.value = "الكمية"; datagridview1.columns[5].headercell.value = "تاريخ دخول"; }
surly datatype column varchar.
you need change nvarchar , saved. dont forget add prefix n. refer following query.
if name nvarchar
insert emp (name) values (n'test')
Comments
Post a Comment