The Microsoft jet engine cannot find the input table or query

J

johnBoy

I am new to vb.net and I am trying to add a row of data to an access database.
But I am getting this error above when it gets to the dataAdaptor fill line
of code.
The table and datbase exist and are spelt correctly.
Please has anyone any ideas. Code is below:

Code:

Dim myDataSet As New DataSet()

Try
Dim myOleDbConnection As OleDbConnection
myOleDbConnection = New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=R:\rrep\pid\DataSht.mdb;")
myOleDbConnection.Open()
Dim myOleDbDataAdapter As OleDbDataAdapter
myOleDbDataAdapter = New OleDbDataAdapter("select *
from tbjg", myOleDbConnection)
Dim ditem_tag As New DataColumnMapping("item_tag", "item_tag")
Dim ddtemp As New DataColumnMapping("temp", "temp")
Dim ddpress As New DataColumnMapping("press", "press")
myOleDbDataAdapter.Fill(myDataSet, "Articles")

Dim rowArticle As DataRow = myDataSet.Tables(0).NewRow()
rowArticle("item_tag") = "1100-B-222"
rowArticle("temp") = "250"
rowArticle("press") = "15"
myDataSet.Tables(0).Rows.Add(rowArticle)

myOleDbDataAdapter.Update(myDataSet, "Articles")
myDataSet.Tables("Articles").AcceptChanges()

Catch ex As OleDbException
' Reject DataSet changes
MessageBox.Show(ex.Message)

End Try
 
P

Paul Clement

¤ I am new to vb.net and I am trying to add a row of data to an access database.
¤ But I am getting this error above when it gets to the dataAdaptor fill line
¤ of code.
¤ The table and datbase exist and are spelt correctly.
¤ Please has anyone any ideas. Code is below:

Have you tried compacting the database? It's possible that it may be corrupt.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
J

johnBoy

Hi Paul,

Yes, I have compacted the database and have created a new database, but
still getting the same error. This is very frustrating.

John
 
W

William \(Bill\) Vaughn

Okay, let's see if we can help you find the problem.
Have you opened the Database in the Server/Database explorer? If so, does
the table in question exist? Let's assume it does.
Is myOleDbDataAdapter.Fill(myDataSet, "Articles") returning a populated
Dataset or is this where the program is failing?
If so, remove the column mappings and see if that permits the Fill to
execute. If it does, you have a problem with the mappings.

Next, when you add a new row and execute Update, you do NOT need to call
AcceptChanges. Never use AcceptChanges unless you have manually updated the
database and need to reset the rowstate.


--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
J

johnBoy

Hi William,

Thanks for your email.
I viewed the database and table in server explorer, everything looks okay.
I commented out the table mappings and gave it another run.
I am still getting the same error at myOleDbDataAdapter.Fill(myDataSet,
"Articles")
it just won't fill the dataset.

By the way I am running windows xp sp3 with 2.0 .net framework and visual
studio 2005
It seems as if there is some sort of bug

Thanks for your help
John
 
J

johnBoy

Thanks everyone for your help.
I have found the error a miss spelt table name
I had been staring at it for ages now and have only just spotted it.
How embarrassing
 
W

William \(Bill\) Vaughn

No worries. Been there, done that.

I would encourage you to step up to the TableAdapter configuration wizard as
launched by the Data Source config wizard. This eliminates all of this code
and builds strongly typed datasets--and spells all the names correctly. ;)
I discuss all of this in my book--which should be perfect for you as you
transition to more complex applications. At one point in time or another
you'll discover that JET has its limitations so you'll want to evolve your
skills to use SQL Compact or SQL Server. Just consider that JET is being
phased out as its (numerous) problems are not fixable and it is really
unsuitable for today's (and tomorrow's) more sophisticated applications.

hth

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 

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