Tuesday, May 19, 2020

Obtaining the MS Access Connection String for Visual Studio


Introduction
This walk thru will show you how to obtain the connection string for connecting to your MS Access Database.

Procedure
1.    Create a Windows Form App.
2.    Click on “Data Sources” on the left side bar and
3.    Click “Add New Data Source”
4.    Select “Database” and click [Next]
5.    The "Choose a Database Model" dialog box is displayed. Dataset is the only option. Click [Next].
6.    Click on [New Connection]. The "Add Connection" dialog is displayed. Note that the data source needs to be “Microsoft Access Database File (OLE DB)”. If it isn’t, click the [Change] button to select the correct type of data source.
7.    [Browse] to select your MS Access database file.
8.    [Test Connection] will tell you if the connection was successful. Do not change the user name or password.
9.    Click [Ok] to exit the dialog.
10. In the Data Source Configuration Wizard dialog, click on “Show the connection string that you will save in the application”  You should see a connection string similar to the following,
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\CIM.accdb
The string indicates the provider is Microsoft.ACE.OLEDB version 12.0, and the path to the database file.
Copy the connection string to the clip board (select the entire string, the hit Ctrl-C) and paste it into your code to be used when connecting to your MS Access Database.

No comments:

Post a Comment

Solidworks macros eith ChatGPT

 Record a simple using thr Solidworks macro recorder, upload it to ChatGPT, and explain to ChatGPT how you want it changed:  https://youtu.b...