我在sql中搜索并在gridview中显示数据时遇到问题,我想使用阿拉伯语进行搜索但在gridview中没有显示数据,但如果我使用IDNo = int进行搜索,则表明它正常工作。
zz = "SELECT Name, IDNo, birthplace, Nationality, Mobile, Occupation From PersonalData where Name Like '%" & TextBox1.Text & "%'"
Dim dataadapter As SqlDataAdapter = New SqlDataAdapter(zz, myConnection)
Dim dt As New DataTable("PersonalData")
Dim dsview As New DataTable
Dim bs As New BindingSource
dataadapter.Fill(dt)
DataGridView1.DataSource = dt
答案 0 :(得分:3)
您应该在N
中Like
之前添加N'%"...
"SELECT ...where Name Like N'%" & TextBox1.Text & "%'"
另外 - 注意sql注入,因为它似乎你没有这样做。