OleDbDataReader failure

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

here is a snipet of code i am using

Dim myConnection As New OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\customers\other\g2.mdb")
Dim myCommand As New OleDbCommand("SELECT * FROM catalog
numbers", myConnection)
myConnection.Open()
Dim myReader As OleDbDataReader = myCommand.ExecuteReader
(CommandBehavior.CloseConnection)

the connection opens but the program fails on the
ExcuteReader command. The error is a follows:
"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"

the following import statements are used:
Imports System
Imports System.Data
Imports System.Data.OleDb

any help would be appreciated. thanks
 
Hi Don,

Your sql statament is probably wrong
SELECT * FROM catalog numbers

You should put table in square brackets [catalog numbers].
 
-----Original Message-----
Hi Don,

Your sql statament is probably wrong
SELECT * FROM catalog numbers

You should put table in square brackets [catalog numbers].

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

Don said:
here is a snipet of code i am using

Dim myConnection As New OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\customers\other\g2.mdb")
Dim myCommand As New OleDbCommand("SELECT * FROM catalog
numbers", myConnection)
myConnection.Open()
Dim myReader As OleDbDataReader = myCommand.ExecuteReader
(CommandBehavior.CloseConnection)

the connection opens but the program fails on the
ExcuteReader command. The error is a follows:
"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"

the following import statements are used:
Imports System
Imports System.Data
Imports System.Data.OleDb

any help would be appreciated. thanks


.
 
Also, as you have seen naming items with spaces (while leagal) can cause big
problems later on. It is best not to use spaces in the name of tables,
queries, stored procedures, field names, etc.


Don said:
-----Original Message-----
Hi Don,

Your sql statament is probably wrong
SELECT * FROM catalog numbers

You should put table in square brackets [catalog numbers].

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

Don said:
here is a snipet of code i am using

Dim myConnection As New OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\customers\other\g2.mdb")
Dim myCommand As New OleDbCommand("SELECT * FROM catalog
numbers", myConnection)
myConnection.Open()
Dim myReader As OleDbDataReader = myCommand.ExecuteReader
(CommandBehavior.CloseConnection)

the connection opens but the program fails on the
ExcuteReader command. The error is a follows:
"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"

the following import statements are used:
Imports System
Imports System.Data
Imports System.Data.OleDb

any help would be appreciated. thanks


.
 
Back
Top