ASP connection MySQL Database code

Source: Internet
Author: User
strconnection = "dsn=hc188;driver={myodbd driver};server=localhost;uid=root;pwd=;d atabase=hc188"
Set adodataconn = Server.CreateObject ("Adodb.connection")
Adodataconn.open strconnection


' Method two

strconnection= "Dsn=mysql (the best combination of PHP) test;
Driver={mysql (the best combination with PHP) ODBC 3.51 driver};
Server= fill in the server address; uid= username; pwd= password; database=mm ";

' Look at an example

Dim sconnection, objconn, objRS

' Server is the database host name (the local host uses localhost, remote IP address); database is the name; The UID is the username; password is the password
Sconnection = "Driver={mysql ODBC 3.51 DRIVER}; Server=localhost; database=your_mysql_db; Uid=mysql_username; Password=mysql_password; Option=3 "

Set objconn = Server.CreateObject ("ADODB. Connection ")

objConn.Open (sconnection)
' The following SQL statement is an example statement, please modify it according to the actual situation
Set objRS = objConn.Execute ("Select FirstName, LastName from Tblusers")

While the not objrs.eof ' While...wend loop for reading all information
Response.Write Objrs.fields ("LastName") & "," & Objrs.fields ("FirstName") & "BR"
Objrs.movenext ' recordset pointer moves down
Wend

Objrs.close ' Close the recordset
Set objRS = Nothing ' empties the Recordset, freeing up memory
Objconn.close ' Close Database link
Set objconn = Nothing ' empties the database link, freeing up memory


%>
ASP and MySQL connection currently has two ways: one is the use of components, commonly used is the MYSQLX charge component, and the second is to use MYODBC to connect,

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.