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