
I'm trying to 'refresh' an existing dataset and DataGridView, using the following code, in a click-event routine. I'm sure I've got some of the objects/methods wrong. Can anyone assist ? ( Pages 424-427 ?)
Code:
PrivateSub btnSBig_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles btnSBig.Click
' open the connection.
Dim conn_initialcust AsNew OleDb.OleDbConnection(CONNECT_STRING)
conn_initialcust.Open()
' make a command to select the data
Dim cmd AsNew OleDb.OleDbCommand("SELECT Forename, [Middle Initial], Surname FROM Customers WHERE Surname LIKE 'S*';", conn_initialcust)
' execute the command.
Try
cmd.ExecuteReader()
Catch ex As Exception
MessageBox.Show(ex.Message)
EndTry
conn_initialcust.Close()
conn_initialcust.Dispose()
EndSub
I'm sure the problem's from the ' Dim cmd ' line onwards. Thanks.