asp連接sql資料庫的方法有四種,如下:
第一種寫法:
MM_conn_STRING = "Driver={SQLServer};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={SQLServer};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
以上是asp怎麼連接sql資料庫?的詳細內容。更多資訊請關注PHP中文網其他相關文章!