Command sent to Access Database using OleDbDataAdapter

  • Thread starter Thread starter Ben de Vette
  • Start date Start date
B

Ben de Vette

Hi,

is it possible to see the actual SQL command which is sent to Acces when
using an OleDbDataAdapter?
Al I can see now is that an update command failed.
Why, is not told.

I already found the command string, but it is filled with the question mark
sign which still has to be filled with the parameters. I am looking for the
way to see the actual command sent.

Because, when I replace the ?-signs (by hand) with the provided parameters
in Access itself, everything goes well.

Thanks in advance,
Ben
 
In SQL Server you can use Profiler, but AFAIK, Access provides no similar
functionality.
You can check the Parameters collection, check the ColumnMappings to verify
the columns are mapped correctly and consequently use OnRowUpdating/Updated
to verify the values at any given time.

Those need to correspond to the ? signs. So if you had two columns where
your parameters were mapped to , Column1 and Column2 the First ? would map
to Column1 and the second to Column2. Incorrect positions are a very common
place where things go wrong.

How is it telling you that the command is failing? Are you getting a
specific exception or is it just going back and not updating anything?

If it works by when you add them by hand, I'd verify my postions b/c that's
the most likely cause. Check the column mappings as well. You may be
getting a ConcurrencyException for instance which really isn't a parameter
issue (indirectly it is b/c the parameters are causing the conflict but were
those values not already there or there but apparently changed, then it
would work). I think a routine trapping OnRowUpdating is the closest you
can get with MS Access but I'm no access expert.
http://www.knowdotnet.com/articles/efficient_pt4.html
--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
 
Thanks for the clear answer.
Unfortunaltly, I already used OnRowUpdating/Updated to check for command and
values. I added all the values according to the parameters and the command
did not fail when given in Access itself.

The errormessage given is "Syntax error in UPDATE statement."
Exception thrown is "System.Data.OleDb.OleDbException"

With kind regards,
Ben de Vette
 
Bill,

I read the article and they are clear that even if you discover reserved
words, you should get rid of it in your code. I always define my fields as
constants. So for me it was no problem to changed the field (which I can use
anywhere in the code by refering to the constant) and continue to work.

My problem is that is is TO hard to find the real problem. After a while (3
hours or so) I saw an error code next to the problem text. The text was
"Syntax error in UPDATE statement". which didn't say much. Then I discovered
an errorcode 3000.

Searching for 'access 3000 "Syntax error in UPDATE statement"' in Google, I
found the following link
http://www.vb123.com/toolshed/01_bugs/access_errors.htm, which gave me the
correct explanation (Reserved error).

Thanks again to everybody,
Ben
 
Back
Top