Several common mysql, access, and mssql database connection codes
Introduce three methods for connecting to the mysql tutorial database in adodb
// ------------ Configure the database ----------------
$ Databank = 'mysql ';
$ Mydbhost = "localhost"; // configure the host
$ Mydbuser = "root"; // Database User
$ Mydbpw = "123456"; // Database Password
$ Mydbname = "bianchen"; // Database Password
$ Mydbcharset = "utf8 ";
// Method 1
$ Db = adonewconnection ($ databank );
$ Db-> debug = false;
$ Db-> connect ($ mydbhost, $ mydbuser, $ mydbpw, $ mydbname); // specify that adodb uses the mysql database
$ Db-> execute ('set names utf8 ');
// Method 2
$ Db = newadoconnection ($ databank );
$ Db-> connect ($ mydbhost, $ mydbuser, $ mydbpw, $ mydbname );
$ Db-> execute ("set names 'utf8 '");
// Method 3
$ Db = newadoconnection ($ databank. '://'. $ mydbuser. ':'. $ mydbpw. '@'. $ mydbhost. '/'. $ mydbname. '');
Str = "dsn = mysql; driver = {mysql odbc 3.51 driver}; server = 127.0.0.1; port = 3307; uid = root; pwd =; database = vtigercrm502"
Set conn = server. createobject ("adodb. connection ")
Conn. open str
<%
Set conn = server. createobject ("adodb. connection ")
Conn. connectionstring = "driver = {mysql odbc 3.51 driver };"_
& "Server = localhost ;"_
& "Database = gaorui ;"_
& "Uid = root; pwd = luo; option = 3; stmt = set names gbk"
Conn. open
SQL = "select * from user"
Set rs = conn.exe cute (SQL)
%>
<%
Set conn = server. createobject ("adodb. connection ")
Conn. open "driver = {mysql odbc 3.51 driver}; server = 127.0.0.1; port = 3306; database = gaorui; user = root; password = luo; stmt = set names gbk"
SQL = "select * from user"
Set rs = conn.exe cute (SQL)
%>