you should use ADO.Net Objects
here's the code that you should add to your Button's Click event
'-------this code should be added outside the Button's Click event handler, but this can added inside the Button's
'---Click event handler ------------
Dim Cn as new System.Data.SqlConnection(Your Connection)
Dim sampleAdapter as new System.Data.SqlDataAdapter("SELECT * FROM Table WHERE Column='" & SearchString.ToString() & "'",Cn)
Dim sampleDataset as new Dataset()
'------this code should be added inside the Button's Click event handler -----
Try
sampleAdapter.Fill(sampleDataset,"AnyName")
DataGrid1.DataSource = sampleDataSet.Tables("AnyName")
DataGrid1.DataBind()
Catch exc As Exception
Response.Write(exc.toString())
End Try
'-----this could work but this is not the best code it could be-------
Enter your message below
Sign in or Join us (it's free).