当前位置:Gxlcms > 数据库问题 > asp连接acces数据库

asp连接acces数据库

时间:2021-07-01 10:21:17 帮助过:3人阅读

===============================

‘conn.asp

<%
Dim connstr
connstr="provider=microsoft.ACE.oledb.12.0;data source=" & server.MapPath("database/Config.mdb")
Set conn = Server.Createobject("ADODB.Connection")
conn.Open connstr
%>

===============================

show_config.asp

<!--#include file=conn.asp--> 
        <%
         set rs=server.CreateObject("adodb.recordset")  ‘(建立recordset对象)
         sqlstr="select * from config"  ‘---->(message为数据库中的一个数据表,即你要显示的数据所存放的数据表)
         rs.open sqlstr,conn,1,3        ‘ ---->(表示打开数据库的方式)

  

         rs.movefirst                    ‘---->(将指针移到第一条记录)
         while not rs.eof                ‘---->(判断指针是否到末尾)
         response.write(rs("web_name"))   ‘   ---->(显示数据表message中的name字段)
   ‘response.write(rs("info"))
   ‘Response.write("<br/>")
         rs.movenext                     ‘---->(将指针移动到下一条记录)
         wend                            ‘---->(循环结束)

  
‘------------------------------------------------------        
         rs.close
         conn.close                    ‘这几句是用来关闭数据库
         set rs=nothing
         set conn=nothing
‘-------------------------------------------------------
        %>


 

 

 

 

 

asp连接acces数据库

标签:

人气教程排行