如何知道一个ACCESS表字段的各种属性如其默认值是多少,是否允许空字符串,是否是必填字段,是否有索引等?谁能解决,高分200相送

hchxxzx 2002-08-30 10:09:58
如何知道一个ACCESS表字段的各种属性如其默认值是多少,该字段创建时候的说明文字是什么,是否允许空字符串,是否是必填字段,是否有索引等?谁能解决,高分200相送。
如果能再说一下如何用SQL语句创建表的时候如何创建上述内容的,再送200分(另开贴)
...全文
694 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
hchxxzx 2002-09-18
  • 打赏
  • 举报
回复
不好意思,前一段时间没空来,几乎把这个帖子都忘记了。现在结贴
hchxxzx 2002-09-06
  • 打赏
  • 举报
回复
nice90(我爱射雕,更爱蓉儿)
不好意思,我把你上面的程序稍稍修改了一下,去除条件,程序如下所示。
似乎是少了一个INCLUE文件,<!--#include file="adovbs.inc"-->,不过好像又跟它没有关系。
主要问题是我一运行它,就提示“ 对象或提供程序不能执行所需的操作。”,错误是相同的,就是on error resume next后面的那一句。不运行它一点问题也没有。
有以教我?

<body bgcolor="#CCCCCC" text="#000000">
<%
table="jyjj"
Path= Server.MapPath("jyjj.mdb")
DSN = "DRIVER=Microsoft Access Driver (*.mdb);UID=admin;ReadOnly=0;PageTimeout=5;FIL=MS Access" & ";DefaultDir=" & Path & ";DBQ=" & Path & ";"
Set con = Server.CreateObject("ADODB.Connection")
con.Open DSN

on error resume next
Set primary = con.OpenSchema(adSchemaPrimaryKeys,Array(empty, empty, table))
if primary("COLUMN_NAME")<>"" then
primarykey=primary("COLUMN_NAME")
end if
primary.close
set primary=nothing
%>
<p class="hei">
</p>
<center>
<table width="650" border="1" cellpadding="0" cellspacing="0">
<tr bgcolor="#CCCCCC">
<th width="61">
<div align="center">字段</div>
</th>
<th width="131">
<div align="center">类型</div>
</th>
<th width="105">
<div align="center">设定大小</div>
</th>
<th width="69">
<div align="center">允许空值</div>
</th>
<th width="69">
自动编号
</th>
<th width="81">主键</th>
<th width="120">
<div align="center">执行操作</div>
</th>
</tr>
<%
Strsql="select * from ["&table&"] "
set objRs=con.execute(Strsql)
for i=0 to objRs.fields.count-1
%>
<tr bgcolor="#CCCCCC">
<td height="2" width="61">
<div align="center"><%=objRs(i).name%></div>
</td>
<td height="2" width="131">
<div align="center">
<%
field_type=objRs(i).type
select case field_type
case adEmpty
typ = "Empty"
case adTinyInt
typ = "TinyInt"
case adSmallInt
typ = "SmallInt"
case adInteger
typ = "Integer"
case adBigInt
typ = "BigInt"
case adUnsignedTinyInt
typ = "UnsignedTinyInt"
case adUnsignedSmallInt
typ = "UnsignedSmallInt"
case adUnsignedInt
typ = "UnsignedInt"
case adUnsignedBigInt
typ = "UnsignedBigInt"
case adSingle
typ = "Single"
case adDouble
typ = "Double"
case adCurrency
typ = "Currency"
case adDecimal
typ = "Decimal"
case adNumeric
typ = "Numeric"
case adBoolean
typ = "Boolean"
case adError
typ = "Error"
case adUserDefined
typ = "UserDefined"
case adVariant
typ = "Variant"
case adIDispatch
typ = "IDispatch"
case adIUnknown
typ = "IUnknown"
case adGUID
typ = "GUID"
case adDATE
typ = "DATE"
case adDBDate
typ = "DBDate"
case adDBTime
typ = "DBTime"
case adDBTimeStamp
typ = "DBTimeStamp"
case adBSTR
typ = "BSTR"
case adChar
typ = "Char"
case adVarChar
typ = "VarChar"
case adLongVarChar
typ = "LongVarChar"
case adWChar
typ = "WChar"
case adVarWChar
typ = "VarWChar"
case adLongVarWChar
typ = "LongVarWChar"
case adBinary
typ = "Binary"
case adVarBinary
typ = "VarBinary"
case adLongVarBinary
typ = "LongVarBinary"
case adChapter
typ = "Chapter"
case adPropVariant
typ = "PropVariant"
case else
typ = "Unknown"
end select
response.write typ
%>
</div>
</td>
<td height="2" width="105">
<div align="center"><%=objRs(i).definedsize%></div>
</td>
<td height="2" width="69">
<div align="center">
<%
attrib=objRs(i).attributes
if (attrib and adFldIsNullable)=0 then response.write "No" else response.write "Yes"
%>
</div>
</td>
<td height="2" width="69">
<div align="center">
<input type="checkbox" name="autoincrement" value="checkbox" <%if objRs(i).Properties("ISAUTOINCREMENT") = True then response.write " checked"%>>
</div>
</td>
<td height="2" width="81">
<div align="center">
<input type="checkbox" name="primarykey" value="checkbox" <%if objRs(i).name=primarykey then response.write " checked"%>>
</div>
</td>
</tr>
<%next %>
</table>
</center>
</body>
<%
objRs.close
Con.close
set objRs=nothing
set Con=nothing
%>
nice90 2002-09-06
  • 打赏
  • 举报
回复
错误在哪儿呢?
什么错误?
hwstu 2002-09-06
  • 打赏
  • 举报
回复
对于默认值可以使用吗???
我测试了一下出现错误的!
nice90 2002-09-05
  • 打赏
  • 举报
回复
上面的link.asp文件我没有加上<%%>,希望你不要忘记了。
link.asp:
<%
''''''''''''''''''''''ADO'''''''''''''''''''''''''''''''''''''
Path= Server.MapPath("mydatabase.mdb")
DSN = "DRIVER=Microsoft Access Driver (*.mdb);UID=admin;ReadOnly=0;PageTimeout=5;FIL=MS Access" & ";DefaultDir=" & Path & ";DBQ=" & Path & ";"
Set con = Server.CreateObject("ADODB.Connection")
con.Open DSN
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
%>
nice90 2002-09-05
  • 打赏
  • 举报
回复
又出错了,应该是<%if session("admin")=true then%>而不是<%if session("admin")=true %>,忘记了then.为什么我总是这么粗心大意的呢?
另外,谢谢你找到那么多关于adovbs.inc里面代码的解释。谢谢!
nice90 2002-09-05
  • 打赏
  • 举报
回复
你所说的这部分并没有错,错在我的代码最后忘记了加上两个end if
请在
<%
objRs.close
Con.close
set objRs=nothing
set Con=nothing
%>

后面加上

<%end if
end if%>
另外,需要将前面的
<%if session("admin")=true %>
改写成<%if session("admin")="" %>
当然在调试的时候,如果你要将这一句去掉,那么你需要将末尾的两个end if中的一个去掉。末尾的另外一个end if是对应if table<>"" then的。你可以测试代码了。我这里是成功了的。
hchxxzx 2002-09-02
  • 打赏
  • 举报
回复
to:nice90(我爱射雕,更爱蓉儿)

下面这一段不能使用,提示出错

错误描述: 对象或提供程序不能执行所需的操作。
错误类别: ADODB.Connection
就是以下第一行出错了。

Set primary = con.OpenSchema(adSchemaPrimaryKeys, _
Array(empty, empty, table))
if primary("COLUMN_NAME")<>"" then
primarykey=primary("COLUMN_NAME")
end if
primary.close
set primary=nothing
hchxxzx 2002-09-02
  • 打赏
  • 举报
回复
我的初衷就是写一个对ACCESS完全备份的东西,把数据库里面的表结构及数据全部倒成SQL语句,有需要恢复的时候运行一下这个语句,则数据库全部重建。写是写好了,也能够用,但发觉重建完成之后,原先表里面的说明文字全部没有了,而且一些原来设置的默认值也不见了,有索引的地方也没有了,所以才来问一下
在MSDN里面找了半天,也没有找到此类的说明,倒是有关于一些简单的,如type,name的求法中文说明,贴出来大家共享一下。


Recordset 对象含有由 Field 对象组成的 Fields 集合。每个 Field 对象对应于 Recordset 中的一列。使用 Field 对象的 Value 属性可设置或返回当前记录的数据。取决于提供者具有的不同功能,Field 对象的某些集合、方法或属性有可能无效。

使用 Field 对象的集合、方法和属性可进行如下操作:

使用 Name 属性可返回字段名。


使用 Value 属性可查看或更改字段中的数据。


使用 Type、Precision 和 NumericScale 属性可返回字段的基本特性。


使用 DefinedSize 属性可返回已声明的字段大小。


使用 ActualSize 属性可返回给定字段中数据的实际大小。


使用 Attributes 属性和 Properties 集合可决定对于给定字段哪些类型的功能受到支持。


使用 AppendChunk 和 GetChunk 方法可处理包含长二进制或长字符数据的字段值。


如果提供者支持批更新,可使用 OriginalValue 和 UnderlyingValue 属性在批更新期间解决字段值之间的差异。
在打开 Field 对象的 Recordset 前,所有元数据属性(Name、Type、DefinedSize、Precision 和 NumericScale)都是可用的。在此时设置这些属性将有助于动态构造其格式。


ActualSize 属性 (ADO)


指示字段的值的实际长度。

设置和返回值

返回长整型值。某些提供者允许设置该属性以便为 BLOB 数据预留空间,在此情况下默认值为 0。

说明

使用 ActualSize 属性可返回 Field 对象值的实际长度。对于所有字段,ActualSize 属性为只读。如果 ADO 无法确定 Field 对象值的实际长度,ActualSize 属性将返回 adUnknown。

如以下范例所示,ActualSize 和 DefinedSize 属性有所不同:使用声明类型 adVarChar 且最大长度为 50 个字符的 Field 对象,将返回值为 50 的 DefinedSize 属性。但是返回的 ActualSize 属性值是在当前记录的字段中所存储的数据的长度。


Attributes 属性 (ADO)


指示对象的一项或多项特性。

设置和返回值

设置或返回长整型值。

对于 Connection 对象,Attributes 属性为读/写,并且其值可能为以下任意一个或多个 XactAttributeEnum 值的和(默认为零)。

常量 说明
AdXactCommitRetaining 执行保留的提交,即通过自动调用 CommitTrans 启动新事务。并非所有提供者都支持该常量。
AdXactAbortRetaining 执行保留的中止,即通过自动调用 RollbackTrans 启动新事务。并非所有提供者都支持该常量。


对于 Parameter 对象,Attributes 属性为读/写,并且其值可能为以下任意一个或多个 ParameterAttributesEnum 值的和。

常量 说明
AdParamSigned 默认值。指示该参数接受带符号的值。
AdParamNullable 指示该参数接受 Null 值。
AdParamLong 指示该参数接受长二进制数据。


对于 Field 对象,Attributes 属性为只读,其值可能为以下任意一个或多个 FieldAttributeEnum 值的和。

常量 说明
adFldMayDefer 指示延迟该字段,即不使用整个记录从数据源检索该字段值,只有在显式访问这些字段时才能对其进行检索。
adFldUpdatable 指示可以写入该字段。
adFldUnknownUpdatable 指示提供者无法确定是否可以写入该字段。
adFldFixed 指示该字段包含定长数据。
adFldIsNullable 指示该字段接受 Null 值。
adFldMayBeNull 指示可以从该字段读取 Null 值。
adFldLong 指示该字段为长二进制字段。并指示可以使用 AppendChunk 和 GetChunk 方法。
adFldRowID 指示该字段含有无法写入的持久行标识符,且该字段除了对行进行标识(如记录号、唯一标识符等)外不存在有意义的值。
adFldRowVersion 指示该字段包含用来跟踪更新的某种时间或日期标记。
adFldCacheDeferred 指示提供者缓存了字段值,并已完成随后对缓存的读取。


对于 Property 对象,Attributes 属性为只读,并可能是以下任意一个或多个 PropertyAttributesEnum 值的和:

常量 说明
adPropNotSupported 指示提供者不支持该属性。
adPropRequired 指示数据源初始化之前用户必须指定该属性的值。
adPropOptional 指示数据源初始化之前用户不必为该属性指定值。
adPropRead 指示用户可以读取该属性。
adPropWrite 指示用户可以设置该属性。


说明

使用 Attributes 属性可设置或返回 Connection 对象、Paramete 对象、Field 对象或 Property 对象的特性。

设置多个属性时,可以将相应的常量相加。如果将属性值设置为包括不兼容常量的总和,那么将产生错误。

Remote Data Service 的用法 该属性在客户端的 Connection 对象上无效。


DefinedSize 属性 (ADO)


指示 Field 对象所定义的大小。

返回值

返回反映某个字段定义大小(按字节数)的长整型值。

说明

使用 DefinedSize 属性可确定 Field 对象的数据容量。

DefinedSize 属性与 ActualSize 属性不同。例如,某个 Field 对象其声明类型为 adVarChar,DefinedSize 属性值为 50,并包含单个字符。该对象返回的 ActualSize 属性值为单个字符的字节长度。


Name 属性 (ADO)


指示对象的名称。

设置和返回值

设置或返回字符串值。该值在 Command 或 Parameter 对象上为读/写,在 Property 或 Field 对象上为只读。

说明

使用 Name 属性可将名称赋给 Command、Field、Parameter 或 Property 对象,或检索它们的名称。

对于还没有追加到 Parameters 集合中的 Parameter 对象,Name 属性为读/写。对于已经追加的 Parameter 对象以及所有其他对象,Name 属性为只读。在集合中名称不必唯一。

可以按照序列索引检索对象的 Name 属性,在此之后则可以直接使用名称引用对象。例如,如果 rstMain.Properties(20).Name 为 Updatability,可以随后将该属性引用为 rstMain.Properties("Updatability")。


NumericScale 属性 (ADO)


指示 Parameter 或 Field 对象中数字值的范围。

设置和返回值

设置或返回 Byte 值,指示数字值所精确到的小数点位数。

说明

使用 NumericScale 属性可确定用于表明数字型 Parameter 或 Field 对象的值的小数位数。

对于 Parameter 对象,NumericScale 属性为读/写。对于 Field 对象,NumericScale 属性为只读。


NumericScale 属性 (ADO)


指示 Parameter 或 Field 对象中数字值的范围。

设置和返回值

设置或返回 Byte 值,指示数字值所精确到的小数点位数。

说明

使用 NumericScale 属性可确定用于表明数字型 Parameter 或 Field 对象的值的小数位数。

对于 Parameter 对象,NumericScale 属性为读/写。对于 Field 对象,NumericScale 属性为只读。


OriginalValue 属性 (ADO)


指示发生任何更改前已在记录中存在的 Field 的值。

返回值

返回变体型值。

说明

使用 OriginalValue 属性可返回当前记录中某字段的原始字段值。

在立即更新模式(一旦您调用 Update 方法,提供者会将更改写入现行数据源)中,OriginalValue 属性返回在发生任何更改前(即自从上次调用 Update 方法)已经存在的字段值。该值与 CancelUpdate 方法用来替换 Value 属性的值相同。

在批更新模式(只有在调用 UpdateBatch 方法时提供者才缓存多个更改并将其写入现行数据源)下,OriginalValue 属性返回在发生任何更改前(即自从调用 UpdateBatch 方法)已经存在的字段值。该值与 CancelUpdate 方法用来替换 Value 属性的值相同。与 UnderlyingValue 属性一起使用该属性时,可以解决由批更新引起的冲突。


Precision 属性 (ADO)


指示在 Parameter 对象中数字值或数字 Field 对象的精度。

设置和返回值

设置或返回 Byte 值,用来表示值的最大位数。该值在 Parameter 对象上为读/写,而在 Field 对象上为只读。

说明

使用 Precision 属性可确定表示数字 Parameter 或 Field 对象值的最大位数。


Type 属性 (ADO)


指示 Parameter、Field 或 Property 对象的操作类型或数据类型。

设置和返回值

设置或返回下列 DataTypeEnum 值之一。相应的 OLE DB 类型标识符在下表的说明栏的括号中给出。有关 OLE DB 数据类型的详细信息,请参阅第 10 章和《 OLE DB 参考手册》的附录 A。

常量 说明
adArray 与其他类型一起加入逻辑 OR 以指示该数据是哪种类型的安全数组 (DBTYPE_ARRAY)。
adBigInt 8 - 字节带符号的整数 (DBTYPE_I8)。
adBinary 二进制值 (DBTYPE_BYTES)。
adBoolean 布尔型值 (DBTYPE_BOOL)。
adByRef 与其他类型一起加入逻辑 OR 以指示该数据是其他类型数据的指针 (DBTYPE_BYREF)。
adBSTR 以空结尾的字符串 (Unicode) (DBTYPE_BSTR)。
adChar 字符串值 (DBTYPE_STR)。
adCurrency 货币值 (DBTYPE_CY)。货币数字的小数点位置固定、小数点右侧有四位数字。该值保存为 8 字节的范围为 10,000 的带符号整型值。
adDate 日期值 (DBTYPE_DATE)。日期按双精度型数值来保存,数字全部表示从 1899 年 12 月 30 开始的日期数。小数部分是一天当中的片段时间。
adDBDate 日期值 (yyyymmdd) (DBTYPE_DBDATE)。
adDBTime 时间值 (hhmmss) (DBTYPE_DBTIME)。
adDBTimeStamp 时间戳(yyyymmddhhmmss 加 10 亿分之一的小数)(DBTYPE_DBTIMESTAMP).
adDecimal 具有固定精度和范围的精确数字值 (DBTYPE_DECIMAL)。
ad
tripofdream 2002-09-02
  • 打赏
  • 举报
回复
(只适用于Jet引擎)
tripofdream 2002-09-02
  • 打赏
  • 举报
回复
objRs(i).Required是否允许NULL.
nice90 2002-09-01
  • 打赏
  • 举报
回复
上面还可以使用objRs(i).DefaultValue来查看默认值。
nice90 2002-08-31
  • 打赏
  • 举报
回复
link.asp:
''''''''''''''''''''''ADO'''''''''''''''''''''''''''''''''''''
Path= Server.MapPath("mydatabase.mdb")
DSN = "DRIVER=Microsoft Access Driver (*.mdb);UID=admin;ReadOnly=0;PageTimeout=5;FIL=MS Access" & ";DefaultDir=" & Path & ";DBQ=" & Path & ";"
Set con = Server.CreateObject("ADODB.Connection")
con.Open DSN
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

property.asp:

<%if session("admin")=true then%>
<!--#include file="adovbs.inc"-->
<!--#include file="link.asp"-->
<body bgcolor="#CCCCCC" text="#000000">
<%
'接收从上个页面传递过来的表名
%>
<p class="hei">
<%
on error resume next
table=request.QueryString("table")
if table<>"" then
response.write "数据表:"&table
Set primary = con.OpenSchema(adSchemaPrimaryKeys, _
Array(empty, empty, table))
if primary("COLUMN_NAME")<>"" then
primarykey=primary("COLUMN_NAME")
end if
primary.close
set primary=nothing
%>
</p>
<center>
<table width="650" border="1" cellpadding="0" cellspacing="0">
<tr bgcolor="#CCCCCC">
<th width="61">
<div align="center">字段</div>
</th>
<th width="131">
<div align="center">类型</div>
</th>
<th width="105">
<div align="center">设定大小</div>
</th>
<th width="69">
<div align="center">允许空值</div>
</th>
<th width="69">
自动编号
</th>
<th width="81">主键</th>
<th width="120">
<div align="center">执行操作</div>
</th>
</tr>
<%Strsql="select * from ["&table&"] "
set objRs=con.execute(Strsql)
for i=0 to objRs.fields.count-1
%>
<tr bgcolor="#CCCCCC">
<td height="2" width="61">
<div align="center"><%=objRs(i).name%></div>
</td>
<td height="2" width="131">
<div align="center">
<%
field_type=objRs(i).type
select case field_type
case adEmpty
typ = "Empty"
case adTinyInt
typ = "TinyInt"
case adSmallInt
typ = "SmallInt"
case adInteger
typ = "Integer"
case adBigInt
typ = "BigInt"
case adUnsignedTinyInt
typ = "UnsignedTinyInt"
case adUnsignedSmallInt
typ = "UnsignedSmallInt"
case adUnsignedInt
typ = "UnsignedInt"
case adUnsignedBigInt
typ = "UnsignedBigInt"
case adSingle
typ = "Single"
case adDouble
typ = "Double"
case adCurrency
typ = "Currency"
case adDecimal
typ = "Decimal"
case adNumeric
typ = "Numeric"
case adBoolean
typ = "Boolean"
case adError
typ = "Error"
case adUserDefined
typ = "UserDefined"
case adVariant
typ = "Variant"
case adIDispatch
typ = "IDispatch"
case adIUnknown
typ = "IUnknown"
case adGUID
typ = "GUID"
case adDATE
typ = "DATE"
case adDBDate
typ = "DBDate"
case adDBTime
typ = "DBTime"
case adDBTimeStamp
typ = "DBTimeStamp"
case adBSTR
typ = "BSTR"
case adChar
typ = "Char"
case adVarChar
typ = "VarChar"
case adLongVarChar
typ = "LongVarChar"
case adWChar
typ = "WChar"
case adVarWChar
typ = "VarWChar"
case adLongVarWChar
typ = "LongVarWChar"
case adBinary
typ = "Binary"
case adVarBinary
typ = "VarBinary"
case adLongVarBinary
typ = "LongVarBinary"
case adChapter
typ = "Chapter"
case adPropVariant
typ = "PropVariant"
case else
typ = "Unknown"
end select
response.write typ%>
</div>
</td>
<td height="2" width="105">
<div align="center"><%=objRs(i).definedsize%></div>
</td>
<td height="2" width="69">
<div align="center">
<%
attrib=objRs(i).attributes
if (attrib and adFldIsNullable)=0 then
response.write "No"
else
response.write "Yes"
end if
%>
</div>
</td>
<td height="2" width="69">
<div align="center">
<%if objRs(i).Properties("ISAUTOINCREMENT") = True then%>
<input type="checkbox" name="autoincrement" value="checkbox" checked>
<%else%>
<input type="checkbox" name="autoincrement" value="checkbox">
<%end if%>
</div>
</td>
<td height="2" width="81">
<div align="center">
<%if objRs(i).name=primarykey then%>
<input type="checkbox" name="primarykey" value="checkbox" checked>
<%else%>
<input type="checkbox" name="primarykey" value="checkbox">
<%end if%>
</div>
</td>
</tr>
<%next %>
</table>
</center>
</body>
<%
Con.close
objRs.close
set Con=nothing
set objRs=nothing
%>

上面仅仅列出了你需要的一部分内容,关于默认值和说明文字还有索引没有做出来,希望听听别人的高见!
S.F. 2002-08-31
  • 打赏
  • 举报
回复
没有办法帮你写代码;可惜可惜,这个分是要不到了;

不过还是可以推荐你去msdn.microsoft.com 查看ado部分;里面有各种各样的示例,总比在这里发帖子去问强多了
哈哈,基本上可以作个完整的数据库管理程序了。

hwstu 2002-08-31
  • 打赏
  • 举报
回复
好up
saucer 2002-08-31
  • 打赏
  • 举报
回复
use ADOX library, for example

<%
Dim conn
Dim cat
Dim tblOD
Dim colLoop
Dim idxLoop

set conn = Server.CreateObject("ADODB.Connection")

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\somedb.mdb;User ID=Admin;Password=;"

set cat = Server.CreateObject("ADOX.Catalog")
Set cat.ActiveConnection = conn

Set tblOD = cat.Tables("YourTableName")
%>
Column Information:
<table border="1" cellspacing="0" cellpadding="0">
<thead>
<th>Column Name</th>
<th>Type</th>
<th>NumericScale</th>
<th>Precision</th>
<th>Nullable</th>
</thead>
<%
For Each colLoop In tblOD.Columns
%>
<tr>
<td><%=colLoop.Name%></td>
<td><%=colLoop.Type%></td>
<td><%=colLoop.NumericScale%></td>
<td><%=colLoop.Precision%></td>
<td><%=(colLoop.Attributes AND 2) <> 0%></td>
</tr>
<%
Next
%>
</table>

Index information:
<table border="1" cellspacing="0" cellpadding="0">
<thead>
<th>Index Name</th>
<th>Is Primary?</th>
<th>is Unique?</th>
<th>Columns</th>
</thead>
<%
For Each idxLoop In tblOD.Indexes
%>
<tr>
<td><%=idxLoop.Name%></td>
<td><%=idxLoop.PrimaryKey%></td>
<td><%=idxLoop.Unique%></td>
<%
s = ""
For Each colLoop In idxLoop.Columns
s = s & "," & colLoop.Name
Next
if len(s) > 0 then
s = mid(s,2)
end if
%>
<td><%=s%></td>
</tr>
<%
Next

conn.Close
Set cat = Nothing
Set conn = Nothing
%>
hycao 2002-08-30
  • 打赏
  • 举报
回复
如何得到属性不太清楚,但用SQL语句创建表的时候应该可以创建主键、是否非空、默认值、索引。下面是一段vb中的相关代码,稍加改动后应该可以用在asp中:
Dim conn1 As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim SQLStr As String, SQLCreate As String, SQLAlter As String
SQLStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\abc.mdb;"
Set conn1 = New ADODB.Connection
conn1.ConnectionString = SQLStr
conn1.Open
SQLCreate = "create table temptable" & _
"(H_ID int not null constraint H_ID_PK primary key," & _
"english char(30) not null default ENG," & _
"chinese char(50) not null default CHN)"
SQLAlter = "create index index_temptable " & _
"on temptable(english)"
Set Rs = conn1.Execute(SQLCreate, 1, adCmdText)
Set Rs = Nothing
Set Rs = conn1.Execute(SQLAlter, 1, adCmdText)
Set Rs = Nothing
lishizhen2002 2002-08-30
  • 打赏
  • 举报
回复
关注。
帮你UP有没有分呢??
呵呵
up

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧