• asp连接mdb数据库,并查询数据展示到web页面


    1. 配置iis详见 

    【转载】https://blog.csdn.net/weixin_46804006/article/details/107346518?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163137524016780265444577%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=163137524016780265444577&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_v2~rank_v29-1-107346518.pc_v2_rank_blog_default&utm_term=IIS&spm=1018.2226.3001.4450

    2. asp连接mdb数据库,并显示到web页面。

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <%
    	session.codepage=65001
    	response.charset="utf-8"
    %>
    
    <%
    '以下是连接数据库
    dim conn,connstr,rs
    Server.ScriptTimeout=900
    connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("test.mdb")
    On Error Resume Next
    	set conn=Server.CREATEOBJECT("ADODB.CONNECTION")
    	conn.Open connstr
    	If Err Then '当连接异常,也就是没有该数据库文件时,输出“数据库连接失败”'
    		err.Clear
    		set conn = Nothing
    		Response.Write "数据库连接失败"
    		Response.End
    	End If
    	set rs=server.createobject("adodb.recordset")
    %>
    <%
    	'sqltext="select * from testT where [userName] like '"&search&"' order by [id] desc"
    	sqltext="select * from testT where [userName] order by [id] asc"
    	'order by [id] desc 表示将id列值由大到小排列
    	rs.open sqltext,conn,1,1
    		i=1
    		do while not rs.EOF
    		%>
    			<%=rs("ID")%>.<%=rs("userName")%><br>
    			<%=rs("sContent")%><hr>
    		<%
    		i=i+1
    		rs.movenext '下一行
    	loop
    %>
    <%
    	rs.addnew
    	rs("name")="amy"
    	rs("sTitle")="我叫小艾米"
    	rs("sContent")="我今年2周岁了,我很开心。"
    	rs.update
    %>
    
    <%
    	rs.close
    	set rs=nothing
    	set conn = nothing
    %>
    

    3. 如果提示连接数据库失败,可执行如下代码

      1. 命令行键入:

      

    cscript.exe %SYSTEMDRIVE%inetpubadminscriptsadsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

      即设置IIS6允许32位程序运行在64位机器上

      2.重新注册.net FrameWorks

    %SYSTEMROOT%Microsoft.NETFrameworkv2.0.50727aspnet_regiis.exe -i
    

      

  • 相关阅读:
    20200816
    20200815
    20200813
    20200811
    20200810
    20200806
    20200804
    20200803
    20200802
    20200801
  • 原文地址:https://www.cnblogs.com/fyc001/p/15257272.html
Copyright © 2020-2023  润新知