How do I set up a connection to an Access database using a SQLConnection? |
 |
EXPERT RESPONSE FROM: Daniel Cazzulino

|
 |
|
| > |
QUESTION POSED ON: 16 January 2004
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.
|
|
|
');
// -->

|
|
 |

 |
 |
Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and
answer pairs from more than 250 TechTarget industry experts.
|
 |
 |
 |
|
 |
 |
 |
|
 |
|
 |