How ADO gets one of the field information for a table in a database

Source: Internet
Author: User
Tags integer
To obtain field information for a table in a database, the properties of the following Recordset object are known to be:

ActualSize property: The actual size of the field.
DefinedSize property: Defines the size of the field.
Type property: Field type, which is represented by the following numbers:
Text text:200
Date Time date:135
Integer int/identification code: 3
Single degree of precision: 4
Double precision: 5
Note memo:201
Whether Yes/no:17
Name property: Field name.
NumericScale property: The number of digits in the field's decimal part.
Precision Property: The maximum number of digits added to the integer and decimal digits of the field.
Example of a field information for a table in a database

Let's look at an example of using Actualsize/definedsize/type/name/numericscale/precision in ASP code.

For example, ASP code rs2.asp as follows:

<%

Set conn1 = Server.CreateObject ("ADODB. Connection ")

Conn1. Open "dbq=" & Server.MapPath ("Ntopsamp.mdb") & ";D river={microsoft Access Driver (*.mdb)};D riverid=25;fil=ms Access; "

Set rs1 = Server.CreateObject ("ADODB. Recordset ")

Rs1. Open "Products", conn1,1,3

Response.Write "Text<br>"

Response.Write "ActualSize:" & Rs1 ("name"). ActualSize & "<BR>"

Response.Write "DefinedSize:" &rs1 ("name"). DefinedSize & "<BR>"

Response.Write "Type:" & Rs1 ("name"). Type & "<BR>"

Response.Write ' Name: ' & rs1 (' name '). Name & "<BR>"

Response.Write "NumericScale:" & Rs1 ("name"). NumericScale & "<BR>"

Response.Write "Precision:" & Rs1 ("name"). Precision & "<p>"

Response.Write "Date<br>"

Response.Write "ActualSize:" & Rs1 ("date"). ActualSize & "<BR>"

Response.Write "DefinedSize:" & Rs1 ("date"). DefinedSize & "<BR>"

Response.Write "Type:" & Rs1 ("date"). Type & "<BR>"

Response.Write "Name:" & Rs1 ("date"). Name & "<BR>"

Response.Write "NumericScale:" & Rs1 ("date"). NumericScale & "<BR>"

Response.Write "Precision:" & Rs1 ("date"). Precision & "<p>"

Response.Write "int/Identification code <BR>"

Response.Write "ActualSize:" & Rs1 ("Price"). ActualSize & "<BR>"

Response.Write "DefinedSize:" & Rs1 ("Price"). DefinedSize & "<BR>"

Response.Write "Type:" & Rs1 ("Price"). Type & "<br>"

Response.Write "Name:" & Rs1 ("Price"). Name & "<BR>"

Response.Write "NumericScale:" & Rs1 ("Price"). NumericScale & "<BR>"

Response.Write "Precision:" & Rs1 ("Price"). Precision & "<p>"

Response.Write "Memo<br>"

Response.Write "ActualSize:" & Rs1 ("Remarks"). ActualSize & "<BR>"

Response.Write "DefinedSize:" & Rs1 ("Remarks"). DefinedSize & "<BR>"

Response.Write "Type:" & Rs1 ("Remarks"). Type & "<BR>"

Response.Write "Name:" & Rs1 ("Remarks"). Name & "<BR>"

Response.Write "NumericScale:" & Rs1 ("Remarks"). NumericScale & "<BR>"

Response.Write "Precision:" & Rs1 ("Remarks"). Precision & "<p>"

Response.Write "Yes<br>"

Response.Write "ActualSize:" & rs1 ("delete"). ActualSize & "<BR>"

Response.Write "DefinedSize:" & rs1 ("delete"). DefinedSize & "<BR>"

Response.Write "Type:" & rs1 ("delete"). Type & "<p>"

%>

The above ASP code rs2.asp the client uses the browser to browse the results of the execution, displaying field information for each field, including the actual size of the field (ActualSize), the defined field size (definedsize), the field type (type), the field name (name), The number of digits (numericscale), integers, and decimal places (Precision), and so on, of the field's decimal parts.

Attributes/state Property

To get more detailed information about the fields of the tables in the database, such as whether the field includes fixed-length data, acceptable null data values, autonumber identifiers, and so on, the properties of the following Recordset object are known:

The Attributes property of the Field object: Represents the state of the fields, added by the following values:
&h00000002: This field is Memo type.
&h00000004: This field can be written to data.
&h00000008: This field is not determined to write data.
&h00000010: This field includes fixed-length data.
&h00000020: This field can accept null data values.
&AMP;H00000040: A data value that may be read to NULL in this field.
&h00000080: This field is a long binary, and you can use the AppendChunk and GetChunk methods.
&AMP;H00000100: This field includes an AutoNumber identification code.
&AMP;H00000200: This field includes the date time.
&h00001000: This field uses cache.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.