April 24th, 2012, 04:15 PM
How can I avoid cross-database references in an insert command?
I am trying to use System.Data.Odbc to work with a Postgres database. I want to use ODBC rather than a dedicated Postgres provider because I want to be able to use DSNs, and I may want this application to address other types of databases.
I use an OdbcCommandBuilder object to set up the commands for my data adapter. When I try to execute the insert command, I get an exception complaining that cross-database references are not implemented. That's because the command text of the insert command begins with something like "insert into MyDatabase.public.MyTable..." I figured this was just a Postgres quirk, and I could just clean up the command text. So, I wrote a little function that would remove the database name and ".public." from the command text. When I ran the modified application, before the adapter's Update() function was called, the insert command was correctly modified to "insert into myTable...". But when the Update() function is executed, the insert command was changed back to the database.schema.table form, and I got the cross-database error again!
Is there a way to stop the adapter object from converting a bare table name to a fully qualified name?
Thank you very much!
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!