OleDbDataReader failure

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
 
M

Miha Markic

Hi Don,

Your sql statament is probably wrong
SELECT * FROM catalog numbers

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

Don

-----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


.
 
S

Scott M.

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


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top