[bo][un]yms123[/un] 在 2008-9-3 10:35 的发言:[/bo]
adox?楼主的代码需要adox组件才能正确执行。
个人记得如果是SQL Server可以通过查询数据库系统的系统表来获得相应表字段的属性。
谢谢版主,adox组件我没能处理,决定放弃,也曾试过用查询数据库系统的系统表来获得相应表字段的属性,但提示我权限不够。现在在网上找到一个方法实现来应付一下,就是通过类型代码转过来,部分代码如下(可能还可以精简):如各位有更好的方法请指出,或有更详细的代码说明请补允,谢谢。
for i=0 to rs.Fields.Count-1
response.write "字段名:"&rs.fields(i).name &"<br>"
response.write "类型:"
if rs.fields(i).type="3" then
response.write "int"
if rs.fields(i).Attributes="16" then response.write "自动编号字段"
if rs.fields(i).Attributes="120" then response.write "允许空"
if rs.fields(i).Attributes="24" then response.write "不允许空"
elseif rs.fields(i).type="129" then
response.write "char"
response.write "大小"&rs.fields(i).DefinedSize
if rs.fields(i).Attributes="120" then response.write "允许空"
if rs.fields(i).Attributes="24" then response.write "不允许空"
elseif rs.fields(i).type="201" then
response.write "text"
if rs.fields(i).Attributes="234" then response.write "允许空"
if rs.fields(i).Attributes="138" then response.write "不允许空"
elseif rs.fields(i).type="202" then
response.write "nvarchar"
response.write "大小"&rs.fields(i).DefinedSize
if rs.fields(i).Attributes="8" then response.write "! 不允许空"
if rs.fields(i).Attributes="104" then response.write "! 允许空"
elseif rs.fields(i).type="131" then
response.write "numeric"
if rs.fields(i).Attributes="120" then response.write "允许空"
if rs.fields(i).Attributes="24" then response.write "不允许空"
elseif rs.fields(i).type="2" then
response.write "smallint"
if rs.fields(i).Attributes="120" then response.write "! 允许空"
if rs.fields(i).Attributes="24" then response.write "! 不允许空"
elseif rs.fields(i).type="11" then
response.write "bit"
if rs.fields(i).Attributes="120" then response.write "! 允许空"
if rs.fields(i).Attributes="24" then response.write "! 不允许空"
elseif rs.fields(i).type="135" then
response.write "smalldatetime"
if rs.fields(i).Attributes="120" then response.write "! 允许空"
if rs.fields(i).Attributes="24" then response.write "! 不允许空"
elseif rs.fields(i).type="203" then
response.write "ntext"
if rs.fields(i).Attributes="234" then response.write "! 允许空"
if rs.fields(i).Attributes="138" then response.write "! 不允许空"
elseif rs.fields(i).type="6" then
response.write "money"
if rs.fields(i).Attributes="120" then response.write "! 允许空"
if rs.fields(i).Attributes="24" then response.write "! 不允许空"
elseif rs.fields(i).type="130" then
response.write "nchar"
if rs.fields(i).Attributes="120" then response.write "! 允许空"
if rs.fields(i).Attributes="24" then response.write "! 不允许空"
elseif rs.fields(i).type="4" then
response.write "real"
if rs.fields(i).Attributes="120" then response.write "! 允许空"
if rs.fields(i).Attributes="24" then response.write "! 不允许空"
elseif rs.fields(i).type="5" then
response.write "flat"
if rs.fields(i).Attributes="120" then response.write "! 允许空"
if rs.fields(i).Attributes="24" then response.write "! 不允许空"
elseif rs.fields(i).type="128" then
response.write "binary"
if rs.fields(i).Attributes="120" then response.write "! 允许空"
if rs.fields(i).Attributes="24" then response.write "! 不允许空"
else
response.write "未知"&rs.fields(i).type
end if
next
[[it] 本帖最后由 随 缘 于 2008-9-4 22:44 编辑 [/it]]