ASPアクセスデータベースに接続するいくつかの方法

1513 ワード

1.比較的古い環境では、2つ目の使用を推奨

set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION") 
DBPath = Server.MapPath("customer.mdb") 
dbconnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath 
SQL="select * from auth where id='" & user_id &"'" 
SET uplist=dbconnection.EXECUTE(SQL) 

2.win 2003以上の機械は、この方法を使うことを提案して、効率はもっと高いです

set dbconnection=Server.CreateObject("ADODB.Connection") 
DBPath = Server.MapPath("customer.mdb") 
dbconnection.Open "provider=microsoft.jet.oledb.4.0;data source="&dbpath 
SQL="select * from auth where id='" & user_id &"'" 
SET uplist=dbconnection.EXECUTE(SQL) 

3.

DBPath = Server.MapPath("customer.mdb") 
set session("rs")=Server.CreateObject("ADODB.Recordset") 
' rs=Server.CreateObject("ADODB.Recordset") 
connstr="provider=microsoft.jet.oledb.4.0;data source="&dbpath 
SQL="select * from auth where id='" & user_id &"'" 
session("rs").Open sql,connstr,1,3 

4.odbcソースxxxを構築する

set conn=server.createobject("Adodb.connection") 
conn.open "DSN=xxx;UID=;PWD=;Database=customer 

5、よく使うsqlserverとaccess共通の接続データベースコードを添付する