ASP中连接数据库的5种方法 <BR>(01-3-30 199) <BR><BR><BR>from: chinaasp.com by caoli <BR><BR><BR>第一种 - 这种方法用在ACCESS中最多 <BR><BR>strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("aspfree.mdb") <BR><BR>set conn = server.createobject("adodb.connection") <BR><BR>conn.open strconn <BR><BR>第二种-这种方法用在SQL SERVER中多 <BR><BR>strconn = "Driver={SQL <BR>Server};Description=sqldemo;SERVER=127.0.0.1;UID=LoginID;PWD=Password;DATABASE=Database_Name <BR><BR>set conn = server.createobject("adodb.connection") <BR><BR>conn.open strconn <BR><BR>第三种 <BR><BR>strconn="Driver={MicrosoftAccessDriver(*.mdb)};" &_ <BR><BR>"DBQ=F:\Inetpub\wwwroot\somedir\db1.mdb;DefaultDir=f:\Inetpub\wwwroot\somedir;uid=LoginID;" &_ <BR><BR>"pwd=Password;DriverId=25;FIL=MSAccess;" set conn = server.createobject("adodb.connection") <BR><BR>conn.open strconn <BR><BR>第四种运用系统数据源 <BR><BR>The following uses a Data Source Name: <BR><BR>set conn = server.createobject("adodb.connection") <BR><BR>conn.open "Example" <BR><BR>第五种运用ODBC数据源,前提是你必须在控制面板的ODBC中设置数据源 <BR><BR>set rs = server.createobject("adodb.recordset") <BR><BR>rs.open "tblname", "DSNName", 3, 3 <BR>
<br>
<CENTER></CENTER>