hello
I'm just starting to switch from VB6 to Visual studio 2012 - Visual basic for applications
In the past i've always connected to my access databases with the code listed below
changing the strSQL string to filter my tables. I tried to keep this simply and clear as possible with the example below
(1) Add a reference "Microsoft DAO 3.6 Object Library" to the project
(2) Add a Module with this code
Global gDatabaseDB As Database
Public Sub OpenDB()
Set gDatabaseDB = OpenDatabase(App.Path & "\Database.Mdb")
End Sub
(3) Add a Form with this code
Option Explicit
Dim rsRs As Recordset
Dim strSQL As String
Private Sub Form_Load()
Call OpenDB
strSQL = "SELECT PatientID,FirstName,LastName,PatientActive FROM Patients ORDER BY LastName,FirstName;"
Set rsRs = gDatabaseDB.OpenRecordset(strSQL, dbOpenSnapshot)
If rsRs.EOF Then 'Test for no records
MsgBox ("No Records")
Else
MsgBox ("Records found")
End If
End Sub
Is there a simply way to get the same results in Visual studio 2012?
I need to change the SQL statements often.
Thanks for any help I can get
I'm just starting to switch from VB6 to Visual studio 2012 - Visual basic for applications
In the past i've always connected to my access databases with the code listed below
changing the strSQL string to filter my tables. I tried to keep this simply and clear as possible with the example below
(1) Add a reference "Microsoft DAO 3.6 Object Library" to the project
(2) Add a Module with this code
Global gDatabaseDB As Database
Public Sub OpenDB()
Set gDatabaseDB = OpenDatabase(App.Path & "\Database.Mdb")
End Sub
(3) Add a Form with this code
Option Explicit
Dim rsRs As Recordset
Dim strSQL As String
Private Sub Form_Load()
Call OpenDB
strSQL = "SELECT PatientID,FirstName,LastName,PatientActive FROM Patients ORDER BY LastName,FirstName;"
Set rsRs = gDatabaseDB.OpenRecordset(strSQL, dbOpenSnapshot)
If rsRs.EOF Then 'Test for no records
MsgBox ("No Records")
Else
MsgBox ("Records found")
End If
End Sub
Is there a simply way to get the same results in Visual studio 2012?
I need to change the SQL statements often.
Thanks for any help I can get