My query file looks like this:
USE DB_A
GO
SELECT * FROM sch.table;
but my connection string, because of some reason, should be forced to set as @"Data Source=SERVER;Initial Catalog=DB_B; ......"
As ExecuteNonQuery() doesn't support GO, this query will be separated into two parts, i.e, actual code looks like this:
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = ConnString;
OleDbCommand cmd = new OleDbCommand();
conn.open();
cmd.ComandText = "USE DB_A";
cmd.ExecuteNonQuery();
cmd.ComandText = "SELECT * FROM sch.table";
cmd.ExecuteNonQuery();
conn.close();
it seemsUSE DATABASE doesn't work, it is still reporting errors cannot find object sch.table when executing.
is there any neat solution other than changing my query file or my connection string?