zoukankan      html  css  js  c++  java
  • 用ASP转化ACCESS数据库为XML文件

    以前写的,今天派上了用场

    核心代码  直接下载
    dim strdataname
    dim strtablename
    dim number
    strdataname
    =request.form("dataname")
    strtablename
    =request.form("tablename")
    ''连接access数据
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open 
    "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("accessdata\"&strdataname) 
    ''建立fso,准本写xml
    set fso=server.createobject("scripting.filesystemobject")
    xmlfile
    =server.mappath("xmldata\data.xml")
    fso.createtextfile(xmlfile)
    set otf=fso.opentextfile(xmlfile,8)
    '开始写xml
    otf.writeline("<?xml version='1.0' encoding='gb2312'?>")
    otf.writeline(
    "<!-- 生成的xml数据仓库 by (卡卡)caca -->")
    otf.writeline(
    "<"&strdataname&">")

    set rs=server.createobject("adodb.recordset")
    sqlstr
    ="select * from "&strtablename
    rs.open sqlstr,conn,
    1,3
    set fld=rs.fields
    rs.movefirst

    '''''''''获取数据表中列的名称<20'''''''''''''
     dim arrclome(30)
     
    for i=0 to fld.count-1
     arrclome(i)
    =rs(i).name
     
    next
     
    while not rs.eof

    otf.writeline(
    "<"&strtablename&">")

    for i=0 to fld.count-1
    otf.writeline(
    "<"&arrclome(i)&">"&rs(arrclome(i))&"</"&arrclome(i)&">")
    next

    otf.writeline(
    "</"&strtablename&">")


    rs.movenext
    wend
    %
    >
    <%
    otf.writeline(
    "</"&strdataname&">")
    %
    >
  • 相关阅读:
    数论&数学中结论证明
    「Uva11401」数三角形
    「CJOJ2725」Wave
    「CJOJ2724」Number
    「CJOJ2723」Reserve
    「CJOJ2722」Ping
    「CJOJ2573」Snake vs Block
    「CJOJ2574」Lucky Transformati
    「CJOJ2721」取石块儿
    「CJOJ2366」机器人采集金属
  • 原文地址:https://www.cnblogs.com/caca/p/126268.html
Copyright © 2011-2022 走看看