gpt4 book ai didi

c# - ConnectionString 中未指定 OLE DB 提供程序。 '供应商= SQLOLEDB;

转载 作者:太空狗 更新时间:2023-10-30 00:41:02 25 4
gpt4 key购买 nike

我尝试使用 C# 运行查询,但遇到以下问题

An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;

我的代码

string strConString = System.Configuration.ConfigurationManager.ConnectionStrings["WorkflowConnStr"].ConnectionString.ToString(); 
string sqlstr = "select * from table"
OleDbConnection myConnection = new OleDbConnection(strConString);
try
{myConnection.Open();}
catch (Exception err)
{ System.Diagnostics.Debug.WriteLine(err.Message); }

OleDbCommand myCommand = new OleDbCommand(sqlstr, myConnection);
OleDbDataReader reader = myCommand.ExecuteReader();

网络配置

<add name="WorkflowConnStr" connectionString="Data Source=Server;Initial Catalog=DBName;user id=usr;password=password" providerName="System.Data.OleDb.OleDbConnection"/>

有什么建议吗?

最佳答案

尝试将其添加到您的连接字符串中,

Provider=SQLNCLI10.1

本来就是这样;

<add name="WorkflowConnStr" connectionString="Data Source=Server;Initial Catalog=DBName;user id=usr;password=password;Provider=SQLNCLI10.1" providerName="System.Data.OleDb.OleDbConnection"/>

关于c# - ConnectionString 中未指定 OLE DB 提供程序。 '供应商= SQLOLEDB;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23192938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com