[英]Keyword not supported 'provider' error
c#.Net 3.5 with a SQL Server 2000 backend, I have a connection string in my app.config file that looks like this c#.Net 3.5带有SQL Server 2000后端,我的app.config文件中有一个连接字符串,如下所示
<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" />
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.
使用此方法创建数据集并拖动DataSource元素以创建DataGridView将填充并成功允许所有CRUD操作。
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.
由于这是SQL Server的旧版本,我假设我必须使用OleDbConnection和其他OleDb对象来完成工作。 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?
不确定为什么这可以通过表单上的数据集工作但我无法创建自己的连接对象...任何想法?
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). 编辑应该注意的是,当我最初创建与此数据库的连接时,它告诉我,我尝试连接的数据库不支持SqlConnection,我必须选择另一个(我当时选择OleDb)。 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,但数据集然后中断...
SqlConnection
适用于SQL 2000.您可以在此处获取连接字符串示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.