Hi,
I am trying to display a DAO.RecordSet in my Datagridview but it is not working. The code compiles and runs but the data does not show in the datagridview. This is what I have tried:
DataGridView4.DataSource = rs
'rs is the recordSet
I would appreciate it if you can give ideas on how I can display this. Using Adodb or oledb is not an option. This is more code:
Code:' Goes before the class Imports DAO ' class member variables Public dbE As DAO.DBEngine Public db As DAO.Database Public sql As String Public rs As DAO.Recordset Public accApp As Object Public dbName As String ' This following code goes inside a sub (function) 'Initialize database dbE = New DAO.DBEngine() Dim a As String, b As Integer, c As String a = Application.StartupPath b = InStr(a, "\bin\Debug") c = a.Substring(0, b) dbName = c & "utility.mdb" db = dbE.OpenDatabase(dbName) accApp = GetObject(dbName) accApp.docmd.setwarnings(False) 'Query and display Dim demand() As Single = Nothing sql = "Select patientName, patientAddress from patientsList where doctor = 'jones'" rs = db.OpenRecordset(sql) ' Do something with the recordset DataGridView4.DataSource = rs rs.Close() 'disconnect from database db.Close() dbE = Nothing accApp = Nothing




Reply With Quote