虽然不喜欢asp(也不咋会弄),但公司工作不能不做,收集一些资料以后用得着
MS Access数据库连接
用DSN连接并且没有用户名和密码:
<% set conn = Server.createObject("ADODB.Connection") conn.open "YourDSNName" %>
用DSN连接并且有用户名和密码:
<% set conn = Server.createObject("ADODB.Connection") conn.open "YourDSNName","username","password" %>
用实际的数据库绝对路径连接:
<% Set conn = Server.createObject("ADODB.Connection") Strconn="DRIVER={Microsoft Access Driver (*.mdb)}; " Strconn=Strconn & "DBQ=e:yanhangdatabase.mdb" conn.Open Strconn %>
用实际的数据库相对路径连接:
<% Set conn = Server.createObject("ADODB.Connection") Strconn="DRIVER={Microsoft Access Driver (*.mdb)}; " Strconn=Strconn & "DBQ=" & Server.MapPath("/database/yanhang.mdb") conn.Open Strconn %>
MS SQL Server数据库连接
用DSN连接:
<% set conn = Server.createObject("ADODB.Connection") conn.open "DSN=MyDSN;UID=user;PWD=password;DATABASE=databasename" %>
不用DSN连接:
<% Set conn = Server.createObject("ADODB.Connection") DSNtemp="DRIVER={SQL Server};SERVER=ServerName;UID=USER;PWD=password;DATABASE=databasename" conn.open DSNtemp %>
FoxPro数据库连接:
<% Set Conn = Server.createObject("ADODB.connection") ConnStr= "Driver=Microsoft Visual Foxpro Driver; UID=userID;SourceType=DBC;SourceDB=C:yanhangdatabase.dbc" Conn.Open ConnStr %>
oracle数据库连接:
<% set conn=server.createobject("adodb.connection") conn.cursorlocation=adUseClient DSNTemp="Provider=MSDAORA.1;Password=xxxxx;User ID=yanhang;Data Source=xxx.world" conn.open DSNtemp %>
评论前必须登录!
注册