Joh*_*ohn 7 sql-server schema odbc connection-string
我有一个旧的asp.net 1项目(它在旧服务器上工作正常,mytable存在于db中.现在我正在尝试将其升级到asp.net 4
我的连接字符串是:
<add key="SqlConnection"
value="DRIVER={SQL Server};SERVER=bel\SQLEXPRESS;Trusted_connection=yes;DATABASE=mydb;option=3;"/>
Run Code Online (Sandbox Code Playgroud)
我收到错误
错误[42S02] [Microsoft] [ODBC SQL Server驱动程序] [SQL Server]无效的对象名称'mytable'.
OdbcCommand dataCommand = new OdbcCommand("select*from mytable",dataConnection);
dataCommand.CommandTimeout = 900;
OdbcDataReader dataReader = dataCommand.ExecuteReader(CommandBehavior.CloseConnection);
当我写SQL时,select * from mydb.dbo.mytable一切正常
我应该在数据库设置(安全性,架构,dbo)或连接字符串中更改什么?
Joh*_*n N 20
我的猜测,看到你正在使用ODBC,你的ODBC连接没有指定默认数据库,所以它使用master.
你可以:
