當(dāng)前位置:首頁(yè)文章首頁(yè) IT學(xué)院 IT技術(shù)

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

作者:  來(lái)源:  發(fā)布時(shí)間:2011-6-24 15:29:45  點(diǎn)擊:

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

//第一種寫(xiě)法:
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 

//第二種寫(xiě)法:(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是修改、刪除、增加開(kāi)關(guān)!

//第三種寫(xiě)法:

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

相關(guān)軟件

相關(guān)文章

文章評(píng)論

軟件按字母排列: 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