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 CHINAZ
//第二种写法:(DSN连接)CHINAZ
MM_conn_STRING="DSN=BBS;UID=SAWD=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
来源:https://blog.csdn.net/candyboy332000/article/details/80375300 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |