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