How can I obtain the MySQL ADO connection string correctly?

Source: Internet
Author: User

Http://database.51cto.com/art/201105/263910.htm

First, you have installed the MySQL database driver correctly.ProgramMysql-connector-odbc-5.1.6-win32.msi)

1. Create an empty file mysql.txt on the table and rename it mysql. udl;

2. Double-click the mysql. udl file to open the "Database Connection Properties" dialog box. On the "providers" Page, select "Micrsoft ole db provider for ODBC drivers" and click "Next;

3. On the "connection" Page, select "use connection string" for "specify data source ";

4. Click "compile" to bring up "Select data source", click "new" on the "file data source" page, and select MySql driver "MySQL ODBC 5.1 Driver" for creating a new data source ";

5. Click "Next", click "Browse", write "MySQL" to the file name in the "Save as" dialog box, click "Next", and click "finish".

6. In the "MySQL connnettor/ODBC data source configuration" dialog box, as required (for example );

7. Click "test" to check whether the connection is successful. The "connenction successful" prompt box appears. For more detailed settings, click "details" and click "OK". The setting is complete;

8. Return to the "Database Connection Properties" dialog box and click "test connection". If the connection is successful, it is the connection string we want.

The following is the ADO connection string tested on my local machine, the server localhost, the database meismon, the username root, and the password 123456.

Provider = msdasql.1; persist Security info = true; extended properties = "driver = MySQL ODBC 5.1 Driver; server = localhost; uid = root; Pwd = 123456; database = seismon; port = 3306; column_size_s32 = 1"

Note:Close "Database Connection Properties" and double-click MySQL again. open the udl dialog box and click "test connection" because of password loss. You can complete the password in the "Database Connection Properties" dialog box, open MySql in text mode. the udl file is a complete connection string.

 

1. Create a new file named ado.txt and rename it "ADO. udl"
Note 1.1: Ado. udl can also be obtained in other ways, but it must be a 0-byte file.
Note 1.2: The system file does not have an extension. In XP Resource Manager, choose tools> Folder Options> View> hide extensions of known file types ", just remove the preceding check box.

2. Double-click the 0-byte ADO. udl file to open the "Data Link Properties" dialog box.

3. On the "Data Link Properties" dialog box "providers" property page, select the driver to connect to the database.
The following example shows how to connect to the access2003 database.

Note 3.1: the figure is slightly different based on the database driver installed on the local machine.

4. click "Next" to go to the "connection" property page. on this page, we need to select the database Driver Based on the database driver selected in the previous step. This page will be different, however, there are many similarities.
We chose the database file of access2003. Since "ADO. udl" and "demo. mdb" are in the same directory, we can directly write the file name.
Click test connection to test whether the database can be connected, as shown in figure

Note 4.1: it is best to use a relative path. Otherwise, the file cannot be found when the software is released.
Note 4.2: escape characters are involved in C. Replace "/" with "//" in the path.
Note 4.3: when connecting to a network database, it is best to check the "allow password" option and write the "user name" and "password" of the correct database ", otherwise, the connection fails because the database connection password is not provided in the connection string in the program.

5. On the "advanced" attribute page, we can set other database settings, such as database access permissions, such

 

6. On the "all" attribute page, you can edit the selected parameters and other additional parameters, such

 

7. Click "OK" to close the "Data Link Properties" dialog box and select "complete". Open the "ADO. udl" file in notepad, as shown in figure

Note 7.1: the connection string can also be directly written as "file name = ADO. udl ""

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.