 |
|
ช่วยหน่อยคร๊า การค้นหาข้อมูล SQL Server ชื่อสินค้า ที่เป็นภาษาไทย ไม่สามารถค้นหาได้ ADO.Net ConnectionString |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub BtnSearch_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles BtnSearch.Click
sql = "SELECT ProductID,ProductName,SalePrice,UnitsInStock FROM Product "
sql &= "WHERE ProductID LIKE'" & TextSearchProduct.Text & "%' OR "
sql &= "ProductName LIKE'" & TextSearchProduct.Text & "%'ORDER BY ProductID ASC "
command = New SqlCommand(sql, connection)
adapter = New SqlDataAdapter(command)
dataSt = New DataSet()
adapter.Fill(dataSt, "product")
DgvCategory.DataSource = dataSt.Tables("product")
Dim headerText() As String = _
{"รหัสสินค้า", "ชื่อสินค้า", "ราคา", "คงคลัง"}
For i = 0 To headerText.Count - 1
DgvCategory.Columns(i).HeaderText = headerText(i)
Next
End Sub
Tag : .NET, Ms SQL Server 2008, VS 2008 (.NET 3.x)
|
|
 |
 |
 |
 |
Date :
2012-05-16 20:12:40 |
By :
Kimlung |
View :
4092 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง Debug ดูค่าตัวแปร sql มาให้ดูหน่อยครับ 
|
 |
 |
 |
 |
Date :
2012-05-17 05:56:45 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ ERROR น่ะค่ะแต่ค้นหาชื่อที่เป็นภาษาไทยไม่ได้ค่ะ

แต่ค้นหาตัวเลขและภาษาอังกฤษได้ค่ะ

ไม่ทราบว่าเกี่ยวกับการตั้งค่าฐานข้อมูลให้รองรับภาษาไทยหรือป่าว
เป็นฐานข้อมูล SQL Database file.mdf ค่ะ
ข้อวิธีการตั่งค่าหน่อยคร๊า
|
 |
 |
 |
 |
Date :
2012-05-17 08:11:00 |
By :
Kimlung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Private Sub BtnSearch_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles BtnSearch.Click
sql = "SELECT ProductID,ProductName,SalePrice,UnitsInStock FROM Product "
sql &= "WHERE ProductID LIKE '" & TextSearchProduct.Text & "%' OR "
sql &= "ProductName LIKE '" & TextSearchProduct.Text & "%' ORDER BY ProductID ASC "
command = New SqlCommand(sql, connection)
adapter = New SqlDataAdapter(command)
dataSt = New DataSet()
adapter.Fill(dataSt, "product")
DgvCategory.DataSource = Nothing
DgvCategory.DataSource = dataSt.Tables("product")
Dim headerText() As String = _
{"รหัสสินค้า", "ชื่อสินค้า", "ราคา", "คงคลัง"}
For i = 0 To headerText.Count - 1
DgvCategory.Columns(i).HeaderText = headerText(i)
Next
End Sub
|
 |
 |
 |
 |
Date :
2012-05-17 09:41:42 |
By :
พี่หมี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แร้วคร๊า ขอบคุงมากนะคร๊า ไป สร้างฐานข้อมูลใหม่ ตั่งค่า column ที่เป็น nverchar หรือ nchar ให้ตั่งค่า Collection เป็น Thai_CI_AS ทั้งหมดคร๊า จึงเพิ่มข้อมูลลงไปใหม่คร๊า
|
 |
 |
 |
 |
Date :
2012-05-17 10:57:36 |
By :
Kimlung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อืม คุ้น ครับ
|
 |
 |
 |
 |
Date :
2012-05-17 12:46:23 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|