vbs生成ACCESS数据里所有表的字段
vbs生成ACCESS数据里所有表的字段
发布时间:2016-12-28 来源:查字典编辑
摘要:databasename="access.mdb"''数据库地址tablename="blogarticle"''要处理的表名Setconn...

<jobid="生成ACCESS数据库里所有表及所有字段并生成一定格式的字符组合">

<scriptlanguage="vbscript">

databasename="access.mdb"''数据库地址

tablename="blogarticle"''要处理的表名

Setconn=CreateObject("ADODB.Connection")

connstr="provider=microsoft.jet.oledb.4.0;datasource="&databasename

conn.Openconnstr

Setrs_all=CreateObject("adodb.recordset")

sql_all="selectnamefromMSysObjectswheretype=1andflags=0"

rs_all.Opensql_all,conn,1,1

DoWhileNotrs_all.EOF

tablename=rs_all(0)

Setrs=CreateObject("adodb.recordset")

sql="select*from"&tablename&"where1<>1"

rs.Opensql,conn,1,1

j=rs.Fields.Count

txtContent=""

txtContent1=""

txtContent2=""

txtContent3=""

txtContent4=""

Fori=0To(j-1)

title=rs.Fields(i).Name

txtContent=txtContent&title&"|"

txtContent1=txtContent1&title&"=trim(request("""&title&"""))"&"<br>"

txtContent2=txtContent2&title&"=rs("""&title&""")<br>"

txtContent3=txtContent3&"rs("""&title&""")=trim(request("""&title&"""))<br>"

txtContent4=txtContent4&title&"=rs("""&title&""")<br>"

Next

yongfa365="<divalign=center><ahref=""http://www.yongfa365.com""class=""titlink""title=""柳永法(yongfa365)'Bloghttp://www.yongfa365.com"">柳永法(yongfa365)'Blog</a>制作</div>"&title&"里的字段<br><br>"

CreateFiletablename&".html",yongfa365&txtContent&"<br><br>"&txtContent1&"<br><br>"&txtContent2&"<br><br>"&txtContent3&"<br><br>"&txtContent4

rs_all.movenext

Loop

FunctionCreateFile(FileName,Content)

SetFSO=CreateObject("Scripting.FileSystemObject")

Setfd=FSO.CreateTextFile(FileName,True)

fd.WriteLineContent

EndFunction

</script>

</job>

<jobid="生成ACCESS数据库里指定表的所有字段并生成一定格式的字符组合">

<scriptlanguage="vbscript">

databasename="access.mdb"''数据库地址

tablename="blogarticle"''要处理的表名

Setconn=CreateObject("ADODB.Connection")

connstr="provider=microsoft.jet.oledb.4.0;datasource="&databasename

conn.Openconnstr

''Setrs_all=CreateObject("adodb.recordset")

''sql_all="selectnamefromMSysObjectswheretype=1andflags=0"

''rs_all.Opensql_all,conn,1,1

''DoWhileNotrs_all.EOF

''tablename=rs_all(0)

Setrs=CreateObject("adodb.recordset")

sql="select*from"&tablename&"where1<>1"

rs.Opensql,conn,1,1

j=rs.Fields.Count

txtContent=""

txtContent1=""

txtContent2=""

txtContent3=""

txtContent4=""

Fori=0To(j-1)

title=rs.Fields(i).Name

txtContent=txtContent&title&"|"

txtContent1=txtContent1&title&"=trim(request("""&title&"""))"&"<br>"

txtContent2=txtContent2&title&"=rs("""&title&""")<br>"

txtContent3=txtContent3&"rs("""&title&""")=trim(request("""&title&"""))<br>"

txtContent4=txtContent4&title&"=rs("""&title&""")<br>"

Next

yongfa365="<divalign=center><ahref=""http://www.yongfa365.com""class=""titlink""title=""柳永法(yongfa365)'Bloghttp://www.yongfa365.com"">柳永法(yongfa365)'Blog</a>制作</div>"&title&"里的字段<br><br>"

CreateFiletablename&".html",yongfa365&txtContent&"<br><br>"&txtContent1&"<br><br>"&txtContent2&"<br><br>"&txtContent3&"<br><br>"&txtContent4

''rs_all.movenext

''Loop

FunctionCreateFile(FileName,Content)

SetFSO=CreateObject("Scripting.FileSystemObject")

Setfd=FSO.CreateTextFile(FileName,True)

fd.WriteLineContent

EndFunction

</script>

</job>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新vbs学习
热门vbs学习
脚本专栏子分类