Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

<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.

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?

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...

like image 802
Mohgeroth Avatar asked Mar 18 '11 20:03

Mohgeroth


1 Answers

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

like image 63
Joe Enos Avatar answered Sep 16 '22 17:09

Joe Enos