For general computer tips and techniques which can help anyone from newbies to experienced users get more out of their computers, check out Computer Secrets Unleashed.
This example executes a Stored Procedure when you load a form. This example uses a Data Grid to store the results.
- 'Create a SqlCommand to represent the query
Dim cmd As SqlCommand = SqlConnection1.CreateCommand
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = txtQuery.Text
- 'Create a SqlDataAdapter to talk to the database
Dim da As SqlDataAdapter = New SqlDataAdapter
da.SelectCommand = cmd
- 'Create a DataSet to hold the results
Dim ds As DataSet = New DataSet
'Fill the Dataset
- 'And bind it to the DataGrid
dgResults.DataSource = ds
dgResults.DataMember = "Results"