Hardcoded database name in generated code
Posted: Fri 12 Nov 2010 23:41
Hi,
I've got a project that uses a different database for production and test. I'm connecting via a Devart.Data.PostgreSql.PgSqlConnection. I've included code that changes the ConnectionString, Port, UserId, Host and Database properties prior to connecting. Outside of the Update function it seems like I am successfully connecting to the correct DB and I'm able to query data etc. However when I use Update I get an exception indicating that cross database queries are not supported. I looked around and found that in some of the auto-generated code in .Designer.vb actually has the name of the default database (that is filled out in the designer) hardcoded into the strings for the Update function (and others):
Me.PgSqlCommand11.CommandText = "INSERT INTO """.""""."""" ...
The above is my redaction of course, the actual code has the actual DB name right in the string. I've globally found the DBName and removed it and gotten the code to work, but I would like to avoid altering generated code. Is there any way to make the generated code DB name agnostic?
Thanks,
Greg
I've got a project that uses a different database for production and test. I'm connecting via a Devart.Data.PostgreSql.PgSqlConnection. I've included code that changes the ConnectionString, Port, UserId, Host and Database properties prior to connecting. Outside of the Update function it seems like I am successfully connecting to the correct DB and I'm able to query data etc. However when I use Update I get an exception indicating that cross database queries are not supported. I looked around and found that in some of the auto-generated code in .Designer.vb actually has the name of the default database (that is filled out in the designer) hardcoded into the strings for the Update function (and others):
Me.PgSqlCommand11.CommandText = "INSERT INTO """.""""."""" ...
The above is my redaction of course, the actual code has the actual DB name right in the string. I've globally found the DBName and removed it and gotten the code to work, but I would like to avoid altering generated code. Is there any way to make the generated code DB name agnostic?
Thanks,
Greg