数据保存为阿拉伯文字母的问号 [英] Data Saved as question marks for arabic letters

查看:99
本文介绍了数据保存为阿拉伯文字母的问号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hey Guys,



我在将数据库中的阿拉伯数据保存到数据库时遇到问题



但它在我的电脑上的数据库上工作正常



i我正在使用带有vb.net的asp.net



insert statment是一个字符串查询



  string  ssql =  插入表(col1,col2,col3)值(' + textbox1。 text +  ',' + textbox2.tex +  ',' + textbox3.text +   ') 





textbox2.text是阿拉伯数据



任何想法???

解决方案

在你的阿拉伯名字之前,应该有大写字母N没有空格...它的作品有效和我一起参加马拉地语

  string  ssql =  插入表(col1,col2,col3)值(N' + textbox1.Text +  ',N' + textbox2.Text +  ',N' + textbox3.Text +  ') 


请尝试这样...

  string  ssql =  插入表(col1,col2,col3)值(' + textbox1 .Text +  ',' +   N + textbox2.Text +  ', ' + textbox3.Tex t +  ') 



I假设 textbox2.Text 是阿拉伯数据。






通过使用参数化查询,您可以消除混乱的字符串连接以及与之相关的其他问题和SQL注入。如果你需要添加另一个参数,将来阅读和更新也会容易得多。



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

com.CommandText = 插入Persons_info(perId,latinName,gender,dob,pob ,电话,护照,curAdd,status)值(@ 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));

com.ExecuteNonQuery();

MessageBox.Show( 保存完成!);


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 asp.net with vb.net

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???

解决方案

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 + "')"


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.


Hi,

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";
cn.Open();
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));

com.ExecuteNonQuery();
 
MessageBox.Show("Saving is done!");


这篇关于数据保存为阿拉伯文字母的问号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆