strQuery +阿拉伯语问题 [英] strQuery +arabic problem
问题描述
我有这个查询
strQuery = string.Format("INSERT INTO [User](UserName,Password,FullName)Values(" {0}," {1}," {2})",txtUserName.Text ,txtPassword.Text,txtFullname.Text);
我的问题是,当我向字段txtUserName插入阿拉伯字符时,UserName字段不接受阿拉伯字符??????
笔记;字段用户名"设置为
[用户名] [nvarchar](100)收集SQL_Latin1_General_CP1_CI_AS NULL,
任何帮助都会很棒
问候
Hi,
i have this Query
strQuery = string.Format("INSERT INTO [User](UserName,Password,FullName) Values(''{0}'',''{1}'',''{2}'')", txtUserName.Text, txtPassword.Text, txtFullname.Text);
my problem is the field UserName doesnot accept arabic charachter when i insert arabic charachter to the field txtUserName it get saved in the db ??????
note; field Usernameis set as
[Username] [nvarchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
any help will be great
Regards
推荐答案
hi,
在查询中,在字段值前使用"N",例如
插入[User](UserName,Password,FullName)值(N''{0}'',''{1}'',''{2}''),txtUserName.Text,txtPassword.Text,txtFullname .Text
请参阅下面的讨论
http://forums.asp.net/t/982003.aspx/1?How + insert + Arabic + urdu + characters + in + SQL + server [
In your query use "N" before your field value for example
INSERT INTO [User](UserName,Password,FullName) Values(N''{0}'',''{1}'',''{2}'')", txtUserName.Text, txtPassword.Text, txtFullname.Text
see the discussion below
http://forums.asp.net/t/982003.aspx/1?How+insert+Arabic+urdu+characters+in+SQL+server[^]
这篇关于strQuery +阿拉伯语问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!