ok, so im trying to execute a query based on the row that a user clicks on...
now for the purpose of testing, the contact_id is set to one, just to ensure that when the code runs it gets an actual data row...
heres my code, that selects an entire row, then simply changes the text on a themed box control...
VB Code:
Private Sub dtaGridContacts_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dtaGridContacts.MouseUp Dim rowPoint = New Point(e.X, e.Y) Dim hti As DataGrid.HitTestInfo = dtaGridContacts.HitTest(rowPoint) If hti.Type = DataGrid.HitTestType.Cell Then dtaGridContacts.CurrentCell = New DataGridCell(hti.Row, hti.Column) dtaGridContacts.Select(hti.Row) End If 'boxContactDetails.Text = "Details: " & dtaGridContacts(hti.Row, 1) & " " & dtaGridContacts(hti.Row, 2) Dim dbCmd As OleDb.OleDbCommand Dim strSQL = "SELECT * FROM Contacts WHERE contact_id='1'" dbCmd = New OleDb.OleDbCommand(strSQL, dbConn) dbConn.Open() Dim dbRead As OleDb.OleDbDataReader = dbCmd.ExecuteReader If dbRead.Read = True Then boxContactDetails.Text = "Details: Of Contact" Else MessageBox.Show("The contact details you requested could not be " & vbCrLf & "displayed. Please hit the refresh button and try again...", "Contact does not exist!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1) End If dbConn.Close() End Sub
i have kept getting this error when i click the grid...this is the error message...
and this is the line that i get the error on...Code:An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
VB Code:
Dim dbRead As OleDb.OleDbDataReader = dbCmd.ExecuteReader
Thanks, Justin




Reply With Quote