I have enetred the code to load the data into the DataGridView dsResults as directed in Chapter 7 but the records do not appear even though Debug displays that 9 records were found. What did I do wrong or whats missing from my code? Please help.
I checked the code over and over and it seems to comply with the code in the book though pointing to my Database.
Is there something else I need to do when using a DataGridView as opposed to a DataGrid which is used in the book?
Here is the code for btnSearchClick
Code:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles btnSearch.Click
Try
Dim custCB As SqlClient.SqlCommandBuilder = New _
SqlClient.SqlCommandBuilder(adapterResults)
Dim clsdatabase As New clsDatabase()
Dim strSQL As String = ""
' Load a DataSet with the complete Products, Customers and
' Customer Contacts tables (to be used later as code tables to display
' choices in a list, etc
dsData = clsdatabase.LoadCompleteDataSet(CONN)
' Load a DataSet with the search results based on the criteria
' specified by the user on the form.
strSQL = BuildSQLStatement()
dsResults = clsdatabase.LoadSearchDataSet(CONN, strSQL)
If dsResults.Tables("Results").Rows.Count > 0 Then
dgdResults.DataSource = dsResults
'dgdResults.Expand(-1)
'dgdResults.NavigateTo(o, Results)
MsgBox("Number of record found = " & dsResults.Tables("Results").Rows.Count)
MsgBox("Found some records matching your search criteria.")
Else
MsgBox("There are no records matching your search criteria.")
End If
Catch
' Error handling goes here
UnhandledExceptionHandler()
End Try
End Sub