I have an old asp.net 1 project (it works fine on old server, mytable exist in db. Now I am trying to upgrade it to asp.net 4
My connection string is:
<add key="SqlConnection"
value="DRIVER={SQL Server};SERVER=bel\SQLEXPRESS;Trusted_connection=yes;DATABASE=mydb;option=3;"/>
I get error
ERROR [42S02] [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'mytable'.
OdbcCommand dataCommand = new OdbcCommand("select * from mytable", dataConnection);
dataCommand.CommandTimeout = 900;
OdbcDataReader dataReader = dataCommand.ExecuteReader(CommandBehavior.CloseConnection);
When I wrote SQL as select * from mydb.dbo.mytable
all works fine
What I should change in db settings (security, schema, dbo) or in connection string?
My guess, seeing that you're using ODBC, is that your ODBC connection doesn't specify a default database, and so it's using master.
You can either:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With