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 %>