Search code examples
c#databasevisual-studio-2010sql-server-2008oledb

Provider field in connection string oledb


Hey guys I'm new to C# and I'm a little confused on the fields that need to be provided in the connection string while using oledb to connect to my sql server 2008 database, particularly one of them.

The "Provider" field is really giving me problems, partially because I'm not really sure what it does. I have tried two different Provider strings and they both come back with the same error:

The "System.Data.SqlClient provider is not registered on the local machine

Or

The "Microsoft.Jet.OLEDB.4.0" provider is not registered on the local machine

Can someone tell me what this means? Also, my task requires me to not use any addition installations, is there a provider that is default?

Thanks


Solution

  • The Microsoft Jet Engine is the database engine used in Microsoft Access. The error simply means that the required Access version is not installed and thus, your application cannot open the OLEDB driver.

    Generally, you should probably just use the System.Data.SqlClient.SqlConnection class instead of the System.Data.OleDb.OleDbConnection class to connect to your SQL Server 2008 database. The connection string should be much simpler.