當前位置:首頁文章首頁 IT學院 IT技術(shù)

ASP與SQL數(shù)據(jù)庫連接代碼(包含四種寫法)

作者:  來源:  發(fā)布時間:2011-6-24 15:29:45  點擊:

下面提供四種關于ASP與SQL數(shù)據(jù)庫連接的代碼分享給大家,希望能夠?qū)Υ蠹矣兴鶐椭?/p>

//第一種寫法:
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")
SQL="SELECT * FROM TABLE ORDER BY ID DESC"
RS.open SQL,CONN,3,3 

//第二種寫法:(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")
SQL="SELECT * FROM TABLE ORDER BY ID DESC"
RS.open SQL,CONN,3,3  // 3,3是修改、刪除、增加開關!

//第三種寫法:

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

相關軟件

相關文章

文章評論

軟件按字母排列: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z