【 tulaoshi.com - ASP 】
若要取得数据库中表的字段信息,由以下RecordSet对象的属性可得知:
ActualSize属性:字段的实际大小。
DefinedSize属性:定义字段的大小。
Type属性:字段类型,使用以下数字代表之:
文字text:200
日期时间date:135
整数int/识别码:3
单精准度:4
双精准度:5
备注memo:201
是否yes/no:17
Name属性:字段名称。
NumericScale属性:字段小数部份的位数。
Precision属性:字段的整数和小数位数部份加起来的最多位数。
取得数据库中表的字段信息例子
让我们看一个在ASP程式码当中使用ActualSize/DefinedSize/ Type/Name/NumericScale/Precision的例子。
譬如ASP程式码rs2.asp如下:
<%
Set conn1 = Server.CreateObject("ADODB.Connection")
conn1.Open "DBQ="& Server.MapPath("ntopsamp.mdb") &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open "产品",conn1,1,3
Response.Write "text<BR"
Response.Write "ActualSize: " & rs1("名称").ActualSize & "<BR"
Response.Write "DefinedSize: " &rs1("名称").DefinedSize & "<BR"
Response.Write "Type: " & rs1("名称").Type & "<BR"
Response.Write "Name: " & rs1("名称").Name & "<BR"
Response.Write "NumericScale: " & rs1("名称").NumericScale & "<BR"
Response.Write "Precision: " & rs1("名称").Precision & "<p"
Response.Write "date<BR"
Response.Write "ActualSize: " & rs1("日期").ActualSize & "<BR"
Response.Write "DefinedSize: " & rs1("日期").DefinedSize & "<BR"
Response.Write "Type: " & rs1("日期").Type & "<BR"
Response.Write "Name: " & rs1("日期").Name & "<BR"
Response.Write "NumericScale: " & rs1("日期").NumericScale & "<BR"
Response.Write "Precision: " & rs1("日期").Precision & "<p"
Response.Write "int/识别码<BR"
Response.Write "ActualSize: " & rs1("价格").ActualSize & "<BR"
Response.Write "DefinedSize: " & rs1("价格").DefinedSize & "<BR"
Response.Write "Type: " & rs1("价格").Type & "<br"
Response.Write "Name: " & rs1("价格").Name & "<BR"
Response.Write "NumericScale: " & rs1("价格").NumericScale & "<BR"
Response.Write "Precision: " & rs1("价格").Precision & "<p"
Response.Write "memo<BR"
Response.Write "ActualSize: " & rs1("备注").ActualSize & "<BR"
Response.Write "DefinedSize: " & rs1("备注").DefinedSize & "<BR"
Response.Write "Type: " & rs1("备注").Type & "<BR"
Response.Write "Name: " & rs1("备注").Name & "<BR"
Response.Write "NumericScal