Private Sub butOk_Click(ByValsender As System.Object, ByVal e As System.EventArgs) Handles but_ok.Click
Dim strConnection As String = "Data Source=your SQL data source;Initial Catalog=your database; Integrated Security=True"
Dim cn As SqlClient.SqlConnection = New SqlClient.SqlConnection(strConnection)
Dim ds As New DataSet
Dim strSelect As String
'strSelect As String
strSelect = "SELECT * FROM " & YourTable & " WHERE [Search Field] = '" & Me.txtName.Text & "'"
Dim dscmd As New SqlClient.SqlDataAdapter(strSelect, cn)
dscmd.Fill(ds, "your table")
Me.Datagrid1.DataSource = ds
Me.Datagrid1.DataMember = "your table"
Dim con As Integer
con = Me.BindingContext(ds, "your table").Count
If con = 0 Then
MessageBox.Show("Recourd could not be found")
End If
End Sub
|