ASP connection MySQL Database code

Source: Internet
Author: User
Tags dsn odbc mysql tutorial mysql database

ASP tutorial link MySQL Tutorial database tutorial several code

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 for database host name (local host with localhost, remote IP address); database is the name; UID is username; password is 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 a sample statement, please modify    
Set objRS = objConn.Execute ("Select FirstName, LastName from Tblusers") and nbsp;  
  
While the not objrs.eof      ' While...wend loop for reading all information & nbsp;  
    Response.Write objrs.fields ("LastName") & "," & Objrs.fields (" FirstName ") &" BR "  
    objrs.movenext   ' recordset pointer Move Down    
wend    
  
Objrs.close ' close recordset    
Set objRS = nothing  ' empty recordset, freeing memory  & nbsp; 
objconn.close  ' close database link    
Set objconn = Nothing ' empty database link, free memory

%>
ASP and MySQL connections currently have two methods: one is to use the component, the MYSQLX charge component is commonly used, and the other 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.