asp连接sqlserver数据库的几种方法

发布时间:2021-01-03编辑:脚本学堂
asp连接sqlserver数据库的几种方法

这里我们介绍三种asp连接sqlserver的方法。

第一种:直接将参数写在配置串中
MM_conn_STRING = "Driver={SQL Server};server=(local);uid=sa;pwd=;database=infs;"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING
SET RS=SERVER.CreateObject("ADOBD.recordset")

第二种:DSN连接,建议采用这种方法,安全,性能好
MM_conn_STRING="DSN=BBS;UID=SA;PWD=12345"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING
SET RS=SERVER.CreateObject("ADOBD.recordset")

第三种:
MM_conn_STRING_own = "Driver={SQL Server};server=(local);uid=sa;pwd=11111;database=infs;"
Set conn = Server.Createobject("ADODB.Connection")
conn.open MM_conn_STRING_own

附access连接语句:
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" _
& Server.MapPath("asp.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn