querying access tables

J

Jochen Becker

Hallo everybody,
the problem goes as follows:
Running a data query to an ACC2000 database from Visual VB or C# using a
WHERE clause is always successful when using DAO, it fails (sometimes) when
using ADODB or ADO.NET. Testing various tables and Queries revealed that the
failure always occurs if the conditions in the WHERE clause contain a
reference to a table field of the combobox type where the data are drawn
from another table.
I have not found any hint to solve this problem( e.g. MSDN kB etc.) and all
my attemps have failed this far.

I have attached at the end one (ADODB) example of many unsuccessful attempts

The error occurs when rec.open(..) is executed.
Using ADO.NET the analogous error occurs when executing
reader = cmd.ExecuteReader()

All the various test codes run fine when no WHERE clause was included or
only fields w/o combo box where addressed in the clause

Who has an idea to overcome this?

Many thnaks for your help in advance

Jochen
-----------------------------------------------

Imports ADODB

Imports System.Data.OleDb

Imports System.Diagnostics

Dim DbSource As String

Dim dbs As New ADODB.Connection

Dim rec As New ADODB.Recordset

Dim dbname, dbadresse, strSQL As String

Dim TimeWindow, CT, LT

Dim FeldWert As Object, FeldWert1 As Object

DbSource = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Replace(dbname, "\", "\\")

strSQL = "SELECT * FROM Preise where preise.Zone='Fern'"

rec.Open(strSQL, dbs, CT, LT, 0)

rec.MoveFirst()

While Not rec.EOF

FeldWert = rec.Fields("zone").Value

MsgBox(FeldWert.ToString)

rec.MoveNext()

End While

rec.Close()

dbs.Close()

------------------------------------------------------

Error message (translated)

A not treated exception of type
'System.Runtime.InteropServices.COMException' occured in AdressenADO.exe.

Additional info: unknown error
 
M

Miha Markic [MVP C#]

Why the heck you use adodb in first place?
What does the error say when run from ado.net?
 
J

Jochen Becker

Hi Miha,
thanks for reply.
Ado.net produces same result and identical error messages.
ADODB was only second attempt after ado.net failed
By the way using Rowset Viewer of the MDAC SDK produces same result.

Jochen
 
M

Miha Markic [MVP C#]

Hi Jochen,

You might send me a simple reproducible sample if you want to.
 
J

Jochen Becker

Hi Miha,
sent by separate mail a short example with a mini ACC2k database and a
VB.net sample as appendices
VB sample contains as far as not selfexplanatory some notes to make it easy
to read -I hope.
thanks for your help

Jochen
 

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