As the name suggests (and the documentation explicitly states), the SqlConnection represents "connection to a SQL Server database." If you're trying to connect to an Access database, you can't use it. You need to use the OleDbConnection, which uses all the drivers that came with the "old" ADO. When you select "New connection" from the dropdown menu for its ConnectionString property, you will get the familiar Data Link dialog. You have to go to the first tab, "Provider", and select the appropriate one for the database you're connecting to, in your case it would be the Microsoft Jet 4.0 (or whichever version you have installed) OLE DB Provider. When you click Next, you will be prompted for the database file and you're set.
Dig Deeper on SQL Server and .NET development
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ... Continue Reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers. Continue Reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.