I am stupidly new to VB.. I have my Class (dalv1) where all my functions are stored and my Main Form.
Code is as follows:
Public Sub getCustomerDetails()
Try
Dim cust_dataTable As New DataTable()
Dim Connection As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source = C:\Users\Public\Documents\VP - A1\Database\Database.mdb"
Dim SQL As String = ("SELECT * FROM tblCustomers")
Dim dataAdapter As New OleDbDataAdapter(SQL, Connection)
dataAdapter.Fill(cust_dataTable)
dataAdapter.Dispose()
Catch ex As Exception
MsgBox("ERROR : " & ex.Message.ToString)
End Try
End Sub
I want to pass the DataTable, cust_dataTable to the Main Form so I can populate text boxes when the form loads.
You need to turn it into a function so that the table gets returned to the caller:
You didn’t share your form’s code, but here is an example of how you would call it: