Update with Join causes exception

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This query runs perfectly within MS Access, yet causes an exception (without
any additional information!) when executed as a command in ADO.NET.

OleDbCommand cmUpd = new OleDbCommand("UPDATE "
+ "DataTarget INNER JOIN DataSource
+ "ON DataTarget.DataID = DataSource.SourceID "
+ "SET "
+ "DataTarget.a = DataSource.a "
+ "WHERE "
+ "DataTarget.a=0", dcUpd);

dcUpd.Open();
cmUpd.ExecuteNonQuery(); //exception!


Data connection is correct and works with other commands.
Other commands are straight selects, updates or inserts.
Only this one is not working.
It seems to be ADO (or the MSAccess data provider) doesn't like the query
itself!

Any ideas?
 
Sylvia,

Your statement looks fine to me except it has a missing " after the word
DataSource. If this is not it can you post the error that you are getting?

Hope this helps
 
Try making a query in Access and using the Command object to call it (as a
stored procedure). You will simply have to pass in the parameter for a to
accomplish this.

The problem: Some Access SQL is not ANSI standard (or T-SQL), so there are
some incompatibilities with ADO and ADO.NET when it comes to Access.


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
<Red faced and embarrassed>
I found the problem. Won't trouble y'all with the details,
trivial unrelated thing I overlooked. Query is indeed fine!

Its late and I need more coffee, methinks!

Many, many thanks for the help!
 
Back
Top