How to access MySQL through ODBC
MySQL ODBC interface is implemented by installing the myodbc driver. Program Is cross-platform. For Linux and other UNIX operating systems, install the third-party ODBC standard support platform, such as iodbc.
Simple ASP exampleCode:Copy codeThe Code is as follows: <%
Dim SQL, MySQL
Set SQL = server. Createobject ("ADODB. Connection ")
MySQL = "driver = {MySQL ODBC 3.51 driver}; database = database;
Server = host; uid = user; Password
= Password; "'option = settings
SQL. Open MySQL
%>
The above Code uses the myodbc development version 3.51 connection example. The development version is used because some new features and stability are not available in the 2.x official version. A few days ago I read an article on how to write a security program written by Microsoft security experts. As mentioned above, if the code of the ASP file is hacked, the database may not be guaranteed, and a series of problems may occur, or even the management permission may be obtained.ArticleAs mentioned above, the solution is to write COM components and then connect to the database by ASP calling the component method. The advantage of doing so is to improve security, but the problem is that there are only a few people capable of doing so. My compromise is to define the data source. The database, user, password, and set connection information are all defined in the data source, which greatly simplifies implementation and enhances security. Of course, to ensure that the data source can be accessed in the actual operating environment, it must be defined as a "system data source ", I think it is harmless to define it as "User Data Source" or "System Data Source" during development.Copy codeThe Code is as follows: <%
Dim SQL
Set SQL = server. Createobject ("ADODB. Connection ")
SQL. Open "DNS = Mysql Data Source Name"
%>