PC Review


Reply
Thread Tools Rate Thread

Command sent to Access Database using OleDbDataAdapter

 
 
Ben de Vette
Guest
Posts: n/a
 
      24th May 2004
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



 
Reply With Quote
 
 
 
 
William Ryan eMVP
Guest
Posts: n/a
 
      24th May 2004
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/
"Ben de Vette" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
Ben de Vette
Guest
Posts: n/a
 
      24th May 2004
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


"William Ryan eMVP" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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/
> "Ben de Vette" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >
> >

>
>



 
Reply With Quote
 
Ben de Vette
Guest
Posts: n/a
 
      24th May 2004
Hi,

FOUND the problem.
I used a reserved word as a fieldname.

Why o Why is access itself not telling me NOT to use this name :-(

So, as always, the problem is easy, but hard to find.
For the people who want to know the reserved words:
http://support.microsoft.com/default...NoWebContent=1

Greetz,
Ben

"Ben de Vette" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
William Ryan eMVP
Guest
Posts: n/a
 
      25th May 2004
hi Ben:

Glad that worked. I have an article about this
http://www.knowdotnet.com/articles/reservedwords.html and it's a common
problem, particularly w/ access. I'm guessing it was giving you the Syntax
error problem?

Anyway, glad it worked.

Bill

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
"Ben de Vette" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> FOUND the problem.
> I used a reserved word as a fieldname.
>
> Why o Why is access itself not telling me NOT to use this name :-(
>
> So, as always, the problem is easy, but hard to find.
> For the people who want to know the reserved words:
>

http://support.microsoft.com/default...NoWebContent=1
>
> Greetz,
> Ben
>
> "Ben de Vette" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Ben de Vette
Guest
Posts: n/a
 
      25th May 2004
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

"William Ryan eMVP" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi Ben:
>
> Glad that worked. I have an article about this
> http://www.knowdotnet.com/articles/reservedwords.html and it's a common
> problem, particularly w/ access. I'm guessing it was giving you the

Syntax
> error problem?
>
> Anyway, glad it worked.
>
> Bill
>
> --
> W.G. Ryan MVP Windows - Embedded
>
> http://forums.devbuzz.com
> http://www.knowdotnet.com/dataaccess.html
> http://www.msmvps.com/williamryan/
> "Ben de Vette" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> >
> > FOUND the problem.
> > I used a reserved word as a fieldname.
> >
> > Why o Why is access itself not telling me NOT to use this name :-(
> >
> > So, as always, the problem is easy, but hard to find.
> > For the people who want to know the reserved words:
> >

>

http://support.microsoft.com/default...NoWebContent=1
> >
> > Greetz,
> > Ben
> >
> > "Ben de Vette" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update command OledbDataAdapter problem explode Microsoft VB .NET 2 23rd Jan 2007 01:03 AM
Re: Correct way of using OleDbDataAdapter and DataSet to update Access database? JoWilliam Microsoft ADO .NET 0 8th Jan 2007 04:12 PM
OleDbDataAdapter Update command updates unmodified rows also Sek Microsoft ADO .NET 2 4th Nov 2005 04:26 PM
OleDbDataAdapter somehow changes passed in path to Access database (VB.NET) id Microsoft Dot NET Framework 0 18th Feb 2004 06:15 AM
OleDbDataAdapter won't update database from dataset M. David Johnson Microsoft ADO .NET 1 10th Jul 2003 04:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:00 PM.