关键字不支持'供应商'的错误 [英] Keyword not supported 'provider' error

查看:144
本文介绍了关键字不支持'供应商'的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#.NET 3.5和SQL Server 2000的后台,我在我的app.config文件的连接字符串,看起来像这样

c#.Net 3.5 with a SQL Server 2000 backend, I have a connection string in my app.config file that looks like this

<add name="MFG_ConnectionString" 
  connectionString="Provider=SQLOLEDB;Data Source=MFG;Persist Security Info=True;Password=kb1234;User ID=kb;Initial Catalog=MFG" 
  providerName="System.Data.OleDb" /> 

此连接字符串是建立与数据源配置向导。创建这个数据集并拖动数据源元素创建一个DataGridView填充,并成功地使所有CRUD操作。

This connection string was built with the data source configuration wizard. Creating a dataset with this and dragging the DataSource element to create a DataGridView populates and successfully allows all CRUD operations.

不过,我不是在寻找通过数据绑定的形式来更改此。我期待这样做背后code中的场景。由于这是SQL Server的旧版本,我假设我必须使用的OleDbConnection等OleDb的对象来完成这项工作。当我尝试执行以下操作:

However, I'm not looking to make changes to this through a databound form. I'm looking to do this behind the scenes in code. Since this is an older version of SQL Server I'm assuming I must use OleDbConnection and other OleDb objects to get the job done. When I try to execute the following:

OleDbConnection visualConnection = new OleDbConnection(ConfigurationManager.ConnectionStrings["MFG_ConnectionString"].ConnectionString);

我得到一个异常:关键字不支持'供应商'
然而,如果我拿出提供商有人告诉我,我必须提供的。不知道为什么这个工程通过表单中的数据集但我不能创建自己的连接对象......什么想法?

I get an exception: "Keyword not supported 'provider'.
Yet if I take out provider I'm told that I must supply one. Not sure why this works through the dataset on the form yet I cannot create my own connection object... any thoughts?

修改的应该注意的是,当我最初创建连接到该数据库,它告诉我,该数据库中,我试图连接到不支持SqlConnection和我必须选择另外一个(我选择是OleDb的当时)。奇怪的是,我认为这方面的工作在幕后为的SqlConnection没有提供在连接字符串中,但该数据集,然后打破...

EDIT It should be noted that when I originally created the connection to this database, it told me that the database I was trying to connect to did NOT support SqlConnection and that I must choose another (my choice being OleDb at that time). It is odd to me that this connection works behind the scenes as SqlConnection without provider in the connection string but the dataset then breaks...

推荐答案

的SqlConnection 正常工作与SQL 2000中你可以得到的ConnectionString样品的这里

SqlConnection works fine with SQL 2000. You can get a connectionstring sample here

这篇关于关键字不支持'供应商'的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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