Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SQL阿拉伯语搜索_C#_Sql_Asp.net_Sql Server_Database - Fatal编程技术网

C# SQL阿拉伯语搜索

C# SQL阿拉伯语搜索,c#,sql,asp.net,sql-server,database,C#,Sql,Asp.net,Sql Server,Database,我在ASP.NETC中有一个带有SQLServer数据库的搜索程序 下拉列表和文本框可在数据库中搜索,但找不到阿拉伯字母 有人有解决办法吗 下面是我的SQL语句代码 void GetContact(string column, string keyword) { con.Open(); SqlCommand com = new SqlCommand(); com.Connection = con; com.CommandType = CommandType.Tex

我在ASP.NETC中有一个带有SQLServer数据库的搜索程序

下拉列表和文本框可在数据库中搜索,但找不到阿拉伯字母

有人有解决办法吗

下面是我的SQL语句代码

void GetContact(string column, string keyword)
{
    con.Open();
    SqlCommand com = new SqlCommand();
    com.Connection = con;
    com.CommandType = CommandType.Text;
    com.CommandText = "SELECT * FROM Contact WHERE " + column +" LIKE '%" + keyword + "%'";
    SqlDataReader data = com.ExecuteReader();
    gvContact.DataSource = data;
    gvContact.DataBind();
    con.Close();
}

您应该使用N'前缀来表示您正在搜索Unicode字符串:

SELECT * 
FROM dbo.tblArticle 
WHERE name LIKE N'%......%'

你的数据库有什么排序规则?希望有帮助:请始终使用参数化查询。这种字符串连接对SQL注入攻击是开放的。还可以使用using语句来处理您的SqlConnection、SqlCommand和SqlDataReaderid没有理解您的观点。您可以向我解释一下吗?我只是尝试一下,它不起作用,可能我的语法错误。您可以为我的代码项目编写语法吗!从联系人中选择*,其中+列+类似于“%+关键字+%”;仅当数据库中的列为NVARCHAR类型时,此操作才有效!很好,谢谢