1、ASP與Access數據庫鏈接代碼1
<%
dim conn,mdbfile
mdbfile=server.mappath("數據庫名稱.mdb")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};uid=admin;pwd=數據庫密碼;dbq="&mdbfile
%>
2、ASP與Access數據庫鏈接代碼2
<%
dim conn,mdbfile
mdbfile=server.mappath("數據庫名稱.mdb")
set conn=server.createobject("adodb.connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdbfile
%>
3、ASP與SQL數據庫鏈接代碼
<%
Const SqlDatabaseName = "數據庫名"
Const SqlPassword = "用戶密碼"
Const SqlUsername = "用戶名"
Const SqlLocalName = "(local)"
dim conn
set conn=server.createobject("ADODB.connection")
conn.open "Provider=Sqloledb;User ID="&SqlUsername&";Password="&SqlPassword&";Initial Catalog="&SqlDatabaseName& ";Data Source="&SqlLocalName&";"
%>
4、ASP與Mysql數據庫鏈接代碼
<%
sqlServerName = "localhost" '服務器名稱或地址
sqlDBUserName = "root" ’數據庫帳號
sqlDBPassword = "admin" '數據庫密碼
sqlDBName = "dbfile" '數據庫名稱
connstr = "driver={MySQL ODBC 3.51 Driver};server="& sqlServerName &";uid="& sqlDBUserName &";pwd="& sqlDBPassword &";database="& sqlDBName &""
set conn = server.createobject("adodb.connection")
conn.open connstr
%>