M
Meissa
Hi all,
I am trying to connect to an Access database on my local machine which
has a table named lastupdate, from this table I want to return the
value to a messagebox of a field named last update which contains the
date that the database was last updated.
I have tried to accomplish this as follows:
Imports System
Imports System.Data
Module Module1
Sub main()
Dim sConnectionString, sSQL As String
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Documents and Settings\Derek\My Documents\Seaton
JFC.mdb;Persist Security Info=False"
sSQL = "SELECT last update FROM lastupdate"
Dim connUP As New OleDb.OleDbConnection(sConnectionString)
Dim cmdUP As New OleDb.OleDbCommand(sSQL, connUP)
Dim drUP As OleDb.OleDbDataReader
connUP.Open()
drUP = cmdUP.ExecuteReader
Do While drUP.Read
MsgBox(drUP.Item("last update"))
Loop
drUP.Close()
connUP.Close()
End Sub
End Module
When I try to run this, I get the following error:
An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in system.data.dll
When I break, the error is at the line : drUP = cmdUP.ExecuteReader
What am I doing wrong here, this is driving me insane.
TIA
Del.
I am trying to connect to an Access database on my local machine which
has a table named lastupdate, from this table I want to return the
value to a messagebox of a field named last update which contains the
date that the database was last updated.
I have tried to accomplish this as follows:
Imports System
Imports System.Data
Module Module1
Sub main()
Dim sConnectionString, sSQL As String
sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Documents and Settings\Derek\My Documents\Seaton
JFC.mdb;Persist Security Info=False"
sSQL = "SELECT last update FROM lastupdate"
Dim connUP As New OleDb.OleDbConnection(sConnectionString)
Dim cmdUP As New OleDb.OleDbCommand(sSQL, connUP)
Dim drUP As OleDb.OleDbDataReader
connUP.Open()
drUP = cmdUP.ExecuteReader
Do While drUP.Read
MsgBox(drUP.Item("last update"))
Loop
drUP.Close()
connUP.Close()
End Sub
End Module
When I try to run this, I get the following error:
An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in system.data.dll
When I break, the error is at the line : drUP = cmdUP.ExecuteReader
What am I doing wrong here, this is driving me insane.
TIA
Del.