ADO如何取得资料表栏位资讯(BIG5)
类别: ASP教程
ADO如何取得儋料表?谖毁Y???
若要取得儋料表?谖毁Y??,由以下RecordSet物件的?傩钥傻弥?:
ActualSize?傩裕捍斯P儋料的?谖???肴大小。
DefinedSize?傩裕捍斯P儋料的所定柳的?谖淮笮 <br> Type?傩裕??谖活?型,使用以下?底执?表之:
文字text:200
日期?r殓date:135
整?甸nt/滓?e瘁:3
?尉??识龋捍
腽精?识龋旱
?湓]memo:201
是否yes/no:17
Name?傩裕??谖幻?费。
NumericScale?傩裕??谖恍??挡糠莸奈??怠<br> Precision?傩裕??谖坏恼??岛托??滴??挡糠菁悠??淼淖疃辔??怠<br> 取得儋料表?谖毁Y??例子
??我??看一??於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 "?a品",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/滓?e瘁<BR>"
Response.Write "ActualSize: " & rs1("?r格").ActualSize & "<BR>"
Response.Write "DefinedSize: " & rs1("?r格").DefinedSize & "<BR>"
Response.Write "Type: " & rs1("?r格").Type & "<br>"
Response.Write "Name: " & rs1("?r格").Name & "<BR>"
Response.Write "NumericScale: " & rs1("?r格").NumericScale & "<BR>"
Response.Write "Precision: " & rs1("?r格").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 "NumericScale: " & rs1("?湓]").NumericScale & "<BR>"
Response.Write "Precision: " & rs1("?湓]").Precision & "<p>"
Response.Write "yes<BR>"
Response.Write "ActualSize: " & rs1("?h除").ActualSize & "<BR>"
Response.Write "DefinedSize: " & rs1("?h除").DefinedSize & "<BR>"
Response.Write "Type: " & rs1("?h除").Type & "<p>"
%>
以上的 ASP程式瘁rs2.asp,於用?舳耸褂??g盂器,?g盂?绦械慕Y果,锢示各?谖坏??谖毁Y??,包括?谖???肴大小(ActualSize)、定柳的?谖淮笮。?DefinedSize)、?谖活?型(Type)、?谖幻?费(Name)、?谖恍??挡糠莸奈??担ㄎumericScale)、整?岛托??滴??底疃辔??担ㄐrecision)等。
Attributes/State?傩约br>
若要取得更????的儋料表?谖毁Y??,譬如此?谖皇欠癜?括固定樘度的儋料、可接受Null的儋料值、是否?樽??泳???的滓?e瘁等,由以下RecordSet物件的?傩钥傻弥?:
Field物件的Attributes?傩裕捍?表?谖坏????B,由以下值相加:
&H00000002:此?谖??轫emo??型。
&H00000004:此?谖豢???入儋料。
&H00000008:不催定此?谖皇欠窨???入儋料。
&H00000010:此?谖话?括固定樘度的儋料。
&H00000020:此?谖豢山邮芪ull的儋料值。
&H00000040:可能坐取到此?谖??槲ull的儋料值。
&H00000080:此?谖??殚L位元(long binary)?谖唬?可使用AppendChunk和GetChunk方法。
&H00000100:此?谖话?括自?泳???的滓?e瘁。
&H00000200:此?谖话?括日期?r殓。
&H00001000:此?谖皇褂勉ache。
Attributes?傩砸部梢允褂渺睹onnection 物件,以取得儋料?爝B??的???B。State?傩燥@示物件的???B:
Connection 物件的Attributes?傩裕捍?表儋料?爝B??的???B,由以下值相加,盍韵值?榘:
&H00020000:正在呼叫CommitTrans。
&H00020000:正在呼叫RollbackTrans。
State?傩裕猴@示物件的???B:
0:物件已??晷檩。
1:物件已??檫??。
??我??看一??於ASP程式瘁??中使用Attributes/State?傩缘睦?子。
譬如ASP程式瘁rs17.asp如下:
<%
Set conn1 = Server.CreateObject("ADODB.Connection")
conn1.Open "DBQ="& Server.MapPath("ntopsamp.mdb") &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"
Response.Write "<BR>conn1.Attributes: " & conn1.Attributes
Response.Write "<BR>conn1.State: " & conn1.Attributes
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.Open "?a品",conn1,1,1
For Each fld In rs2.Fields
Response.Write "<BR>" & fld.Name & "=" & hex(fld.Attributes)
Next
%>
以上的 ASP程式瘁rs17.asp,於用?舳耸褂??g盂器,?g盂?绦械慕Y果,For Each fld In rs2.Fields取得所有?谖坏挠?息。锢示:
?谖活?型?槲淖拄ext?谖弧⑷掌??r殓date ?谖弧⒄??甸nt?谖弧??湓]memo?谖唬??榭???入儋料(&H00000004)、可接受Null的儋料值(&H00000020)、可能坐取到此?谖??槲ull的儋料值(&H00000040)。
?谖活?型?槿掌??r殓date ?谖弧⒄??甸nt?谖唬??楣潭ㄩL度的儋料(&H00000010)。
?谖活?型???湓]memo?谖唬??殚L位元(long binary)?谖唬éamp;H00000040)。
若要取得儋料表?谖毁Y??,由以下RecordSet物件的?傩钥傻弥?:
ActualSize?傩裕捍斯P儋料的?谖???肴大小。
DefinedSize?傩裕捍斯P儋料的所定柳的?谖淮笮 <br> Type?傩裕??谖活?型,使用以下?底执?表之:
文字text:200
日期?r殓date:135
整?甸nt/滓?e瘁:3
?尉??识龋捍
腽精?识龋旱
?湓]memo:201
是否yes/no:17
Name?傩裕??谖幻?费。
NumericScale?傩裕??谖恍??挡糠莸奈??怠<br> Precision?傩裕??谖坏恼??岛托??滴??挡糠菁悠??淼淖疃辔??怠<br> 取得儋料表?谖毁Y??例子
??我??看一??於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 "?a品",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/滓?e瘁<BR>"
Response.Write "ActualSize: " & rs1("?r格").ActualSize & "<BR>"
Response.Write "DefinedSize: " & rs1("?r格").DefinedSize & "<BR>"
Response.Write "Type: " & rs1("?r格").Type & "<br>"
Response.Write "Name: " & rs1("?r格").Name & "<BR>"
Response.Write "NumericScale: " & rs1("?r格").NumericScale & "<BR>"
Response.Write "Precision: " & rs1("?r格").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 "NumericScale: " & rs1("?湓]").NumericScale & "<BR>"
Response.Write "Precision: " & rs1("?湓]").Precision & "<p>"
Response.Write "yes<BR>"
Response.Write "ActualSize: " & rs1("?h除").ActualSize & "<BR>"
Response.Write "DefinedSize: " & rs1("?h除").DefinedSize & "<BR>"
Response.Write "Type: " & rs1("?h除").Type & "<p>"
%>
以上的 ASP程式瘁rs2.asp,於用?舳耸褂??g盂器,?g盂?绦械慕Y果,锢示各?谖坏??谖毁Y??,包括?谖???肴大小(ActualSize)、定柳的?谖淮笮。?DefinedSize)、?谖活?型(Type)、?谖幻?费(Name)、?谖恍??挡糠莸奈??担ㄎumericScale)、整?岛托??滴??底疃辔??担ㄐrecision)等。
Attributes/State?傩约br>
若要取得更????的儋料表?谖毁Y??,譬如此?谖皇欠癜?括固定樘度的儋料、可接受Null的儋料值、是否?樽??泳???的滓?e瘁等,由以下RecordSet物件的?傩钥傻弥?:
Field物件的Attributes?傩裕捍?表?谖坏????B,由以下值相加:
&H00000002:此?谖??轫emo??型。
&H00000004:此?谖豢???入儋料。
&H00000008:不催定此?谖皇欠窨???入儋料。
&H00000010:此?谖话?括固定樘度的儋料。
&H00000020:此?谖豢山邮芪ull的儋料值。
&H00000040:可能坐取到此?谖??槲ull的儋料值。
&H00000080:此?谖??殚L位元(long binary)?谖唬?可使用AppendChunk和GetChunk方法。
&H00000100:此?谖话?括自?泳???的滓?e瘁。
&H00000200:此?谖话?括日期?r殓。
&H00001000:此?谖皇褂勉ache。
Attributes?傩砸部梢允褂渺睹onnection 物件,以取得儋料?爝B??的???B。State?傩燥@示物件的???B:
Connection 物件的Attributes?傩裕捍?表儋料?爝B??的???B,由以下值相加,盍韵值?榘:
&H00020000:正在呼叫CommitTrans。
&H00020000:正在呼叫RollbackTrans。
State?傩裕猴@示物件的???B:
0:物件已??晷檩。
1:物件已??檫??。
??我??看一??於ASP程式瘁??中使用Attributes/State?傩缘睦?子。
譬如ASP程式瘁rs17.asp如下:
<%
Set conn1 = Server.CreateObject("ADODB.Connection")
conn1.Open "DBQ="& Server.MapPath("ntopsamp.mdb") &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"
Response.Write "<BR>conn1.Attributes: " & conn1.Attributes
Response.Write "<BR>conn1.State: " & conn1.Attributes
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.Open "?a品",conn1,1,1
For Each fld In rs2.Fields
Response.Write "<BR>" & fld.Name & "=" & hex(fld.Attributes)
Next
%>
以上的 ASP程式瘁rs17.asp,於用?舳耸褂??g盂器,?g盂?绦械慕Y果,For Each fld In rs2.Fields取得所有?谖坏挠?息。锢示:
?谖活?型?槲淖拄ext?谖弧⑷掌??r殓date ?谖弧⒄??甸nt?谖弧??湓]memo?谖唬??榭???入儋料(&H00000004)、可接受Null的儋料值(&H00000020)、可能坐取到此?谖??槲ull的儋料值(&H00000040)。
?谖活?型?槿掌??r殓date ?谖弧⒄??甸nt?谖唬??楣潭ㄩL度的儋料(&H00000010)。
?谖活?型???湓]memo?谖唬??殚L位元(long binary)?谖唬éamp;H00000040)。
-= 资 源 教 程 =-
文 章 搜 索