People who are new to program development are often confused about how to connect to the database and How to Write connection strings. Service personnel who install products often have a headache about how to quickly test the connection between the local machine and the database. Here, a simple and quick implementation method is provided: *. udl file. (The method is very old, but very practical !)
Step 1: create a data link file.
Right-click and choose "New" to create any types of files, such as text files, and change the name extension to udl, such as DB. udl.
Step 2: connect to the database and test the connection.
Double-click to open the database. in the udl file, the interface shown in appears. Select the database driver and press "Next" To Go To The connection interface. The connection interface varies depending on the driver selected, after entering the relevant information correctly, click "test connection" to test the correctness of the database connection attribute.
Step 3: Obtain the database connection string
In the program, you can connect to the database through the udl file. Of course, it is better to directly connect to the database through the connection string. Open the DB. udl file using notepad and other text tools to obtain the connection string that has just been tested successfully. For example:
[Oledb]
; Everything after this line is an ole db initstring
Provider = msdasql.1; persist Security info = false; user id = APA; Data Source = Apa
With this method, you can quickly and conveniently test the connection with the database and obtain the connection string.
From: http://www.cnblogs.com/gaoweipeng/archive/2009/05/27/1491124.html
Http://www.seoa.cn/html/55.html