热搜词
发表于 2007-2-14 17:09:13 | 显示全部楼层 |阅读模式
&lt;DIV class=NewsContent id=NewsContentLabel><P align=center>ASP与SQL数据库连接代码</P><P>//第一种写法:<BR>MM_conn_STRING = "Driver={SQL Server};server=(local);uid=sa;pwd=;database=infs;"<BR>Set conn = Server.Createobject("ADODB.Connection")<BR>conn.open MM_conn_STRING<BR>SET RS=SERVER.CreateObject("ADOBD.recordset")<BR>SQL="SELECT * FROM TABLE ORDER BY ID DESC"<BR>RS.open SQL,CONN,3,3&nbsp; </P><P>//第二种写法:(DSN连接)</P><P>MM_conn_STRING="DSN=BBS;UID=SA;PWD=12345"<BR>Set conn = Server.Createobject("ADODB.Connection")<BR>conn.open MM_conn_STRING<BR>SET RS=SERVER.CreateObject("ADOBD.recordset")<BR>SQL="SELECT * FROM TABLE ORDER BY ID DESC"<BR>RS.open SQL,CONN,3,3&nbsp; // 3,3是修改、删除、增加开关!</P><P>//第三种写法:</P><P>MM_conn_STRING_own = "Driver={SQL Server};server=(local);uid=sa;pwd=11111;database=infs;"<BR>Set conn = Server.Createobject("ADODB.Connection")<BR>conn.open MM_conn_STRING_own</P><P>//第四种 - 这种方法用在ACCESS中<BR>strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" _<BR>&amp; Server.MapPath("asp.mdb")<BR>set conn = server.createobject("adodb.connection")<BR>conn.open strconn</P>&lt;/DIV>
全部评论0
回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|管理员之家 ( 苏ICP备2023053177号-2 )

GMT+8, 2024-11-25 08:26 , Processed in 0.171203 second(s), 22 queries .

Powered by Discuz! X3.5

Cpoyright © 2001-2024 Discuz! Team