Problem solve Get help with specific problems with your technologies, process and projects.

How do I set up a connection to an Access database using a SQLConnection?

How do I set up a connection to a database using a SQLConnection? I want to connect to an Access database in one of my folders, but the dropdown list of where to connect only gives me the name of my computer. What values do I enter to connect and where? Any help would be appreciated.
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

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.