在ConnectionString中未指定OLE DB提供程序。 “供应商= SQLOLEDB; [英] An OLE DB Provider was not specified in the ConnectionString. 'Provider=SQLOLEDB;

查看:3095
本文介绍了在ConnectionString中未指定OLE DB提供程序。 “供应商= SQLOLEDB;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C#来运行查询,我得到以下问题

i trying to run query using C#, i am getting the following problem

在ConnectionString中未指定OLE DB提供程序。一个例子是,供应商= SQLOLEDB;

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

我的code

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();

的web.config

web.config

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

什么建议吗?

推荐答案

尝试添加这对您的连接字符串,

Try adding this to your connection string,

Provider=SQLNCLI10.1

因此​​,这将是;

So it would be;

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

这篇关于在ConnectionString中未指定OLE DB提供程序。 “供应商= SQLOLEDB;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆