asp 获取access系统表,查询等操作代码
程序员文章站
2022-08-06 08:18:34
方法一:直接用ado的openschema()方法打开adschematables,建立一个schema记录集 code: <% const adschem...
方法一:直接用ado的openschema()方法打开adschematables,建立一个schema记录集
code:
<%
const adschematables = 20
adschemacolumns = 4
dim conn,db
dim connstr
db="temp.mdb" 'access数据库的文件名,请使用相对于网站根目录的的绝对路径
connstr = "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath(db)
set conn = server.createobject("adodb.connection")
conn.open connstr
dim rstschema
dim i
set rstschema = conn.openschema(adschematables)
do while not rstschema.eof
response.write("table name: "& rstschema("table_name") & vbcr & _
"table type: " & rstschema("table_type") & vbcr)
response.write("<br/>")
i = i + 1
rstschema.movenext
loop
rstschema.close
conn.close
%>
方法二:access 系统表 msysobjects 包含了数据库对象列表。尽管未在文档中记载,你仍可通过查询它来获取你想要的。但是默认情况下无法操作系统表,必须手动设定权限收才能查询系统表。
请参考以下动画:如何获取对msysobject的操作权限 http://blog.iyi.cn/user/david/archives/images/msobject.swf
但是我在access2003中找不到这几个系统表,不知道是不是m$增强了access的安全性。
使用下列 sql 语句来获取你想要的
code:
查询:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)=5 order by msysobjects.name;
窗体:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)=-32768 order by msysobjects.name;
表:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (left$([name],4) <> "msys") and (msysobjects.type)=1 order by msysobjects.name;
报表:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)= -32764 order by msysobjects.name;
模块:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)= -32761 order by msysobjects.name;
宏:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)= -32766 order by msysobjects.name;
code:
<%
const adschematables = 20
adschemacolumns = 4
dim conn,db
dim connstr
db="temp.mdb" 'access数据库的文件名,请使用相对于网站根目录的的绝对路径
connstr = "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath(db)
set conn = server.createobject("adodb.connection")
conn.open connstr
dim rstschema
dim i
set rstschema = conn.openschema(adschematables)
do while not rstschema.eof
response.write("table name: "& rstschema("table_name") & vbcr & _
"table type: " & rstschema("table_type") & vbcr)
response.write("<br/>")
i = i + 1
rstschema.movenext
loop
rstschema.close
conn.close
%>
方法二:access 系统表 msysobjects 包含了数据库对象列表。尽管未在文档中记载,你仍可通过查询它来获取你想要的。但是默认情况下无法操作系统表,必须手动设定权限收才能查询系统表。
请参考以下动画:如何获取对msysobject的操作权限 http://blog.iyi.cn/user/david/archives/images/msobject.swf
但是我在access2003中找不到这几个系统表,不知道是不是m$增强了access的安全性。
使用下列 sql 语句来获取你想要的
code:
查询:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)=5 order by msysobjects.name;
窗体:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)=-32768 order by msysobjects.name;
表:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (left$([name],4) <> "msys") and (msysobjects.type)=1 order by msysobjects.name;
报表:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)= -32764 order by msysobjects.name;
模块:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)= -32761 order by msysobjects.name;
宏:
select msysobjects.name from msysobjects where (left([name],1)<>"~") and (msysobjects.type)= -32766 order by msysobjects.name;
上一篇: asp 关键词字符串分割如何实现方法
下一篇: asp 类型转换函数大全第1/2页