我使用此连接来运行我的SQL查询,但它不起作用并发送此错误:
Keyword not supported: 'dsn'
这是我的联系:
public static string CnnStr = @"Dsn=Server;uid=kity;app=Microsoft® Visual Studio® 2010;wsid=kity;database=Server;trusted_connection=Yes";
此连接在我的datalist中适用于我,但对于我的后面代码,它给了我这个错误。我应该说我使用ODBC连接到数据库。
答案 0 :(得分:0)
创建any
.udl 文件
按Enter键
检测您的数据源,并在asp.net代码中复制并粘贴连接字符串
答案 1 :(得分:0)
尝试将providerName=System.Data.Odbc
的值添加到连接字符串中。
像这样:
@"Dsn=Server;uid=kity;app=Microsoft® Visual Studio® 2010;wsid=kity;database=Server;trusted_connection=Yes;providerName=System.Data.Odbc;"
如果这不起作用,请在不同情况下查看相同的问题:
Keyword not supported exception when attempting to use a connection string that points to a ODBC DSN
注意:“不支持关键字:...”错误通常来自格式不正确的连接字符串。