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...
SqlConnection
works fine with SQL 2000. You can get a connectionstring sample here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With