Obtain all the attributes of the Access database field)

Source: Internet
Author: User

To operate the ACCESS database, you need to add a field, but you do not know how to set the attribute of the field. I found some information and found the field attribute.

Then I found some information and used the most stupid way to add all the attributes of the field. Of course, I have never understood why Microsoft does not write these attributes, but uses a set.

First, create an Access database, create a table, and create a field. Set the attributes of the field.

Then read the database with code and list its attributes. You need to reference ADO and ADOX.

Currently, the following attributes are listed:

0 autoincrement
1 default
2 Description
3 nullable
4 Fixed Length
5 Seed
6 Increment
7 jet oledb: column validation text
8 jet oledb: column validation rule
9 jet oledb: iisam not last column
10 jet oledb: autogenerate
11 jet oledb: One blob per page
12 jet oledb: Compressed Unicode strings
13 jet oledb: Allow Zero Length
14 jet oledb: hyperlink

The Code is as follows:

Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. LINQ;
Using system. text;
Using system. Windows. forms;
Using ADOX;
Using ADODB;

Namespace enumcolumnproperties
{
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
}

Private void button#click (Object sender, eventargs E)
{

ADODB. connectionclass conn = new ADODB. connectionclass ();
String connectionstring = @ "provider = Microsoft. Jet. oledb.4.0; Data Source = D: \ firstcatalog. mdb; persist Security info = false ";
Conn. Open (connectionstring, "", "", 0 );


ADOX. catalogclass catalog = new ADOX. catalogclass ();
Catalog. activeconnection = conn;
Foreach (column CO in catalog. Tables [0]. columns)
{
Foreach (ADODB. Property pr in Co. properties)
{
Console. writeline (PR. Name );
}
Console. writeline (Co. Name + "================== ");
}
}
}
}

# C # column

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.