Preparing access code generator [data sorting]

Source: Internet
Author: User
Category: vs2003 C # Application
---------------------------
Data_type list
Note: 130
String 130
Date: 7
Number: 3
---------------------------
Obtain all tables

DB = new dB (this. textbox1.text );
System. Data. datatable schematable = dB. oleconnection. getoledbschematable (system. Data. oledb. oledbschemaguid. Tables, new object [] {null, "table "});
Arraylist Ss = new arraylist ();
For (INT I = 0; I <schematable. Rows. Count; I ++)
{
SS. Add (schematable. Rows [I]. itemarray [2]. tostring ());
}
This. listbox1.datasource = SS;
// System. Windows. Forms. MessageBox. Show (tablenames );
DB. Close ();
------------------------------
Obtain all fields
// System. Windows. Forms. MessageBox. Show (this. listbox1.selectedvalue. tostring ());
DB = new dB (this. textbox1.text );
System. data. datatable schematable = dB. oleconnection. getoledbschematable (system. data. oledb. oledbschemaguid. columns, new object [] {null, null, this. listbox1.selectedvalue. tostring (), null });
Arraylist Ss = new arraylist ();
// This shows the attributes of the Table: used to obtain the table .. Because oledbschemaguid. Tables is changed to oledbschemaguid. columns ..
// For (INT I = 0; I <schematable. Columns. Count; I ++)
//{
// Ss. Add (schematable. Columns [I]. tostring ());
//}
// This is for displaying Columns
For (INT I = 0; I <schematable. Rows. Count; I ++)
{
SS. add (schematable. rows [I]. itemarray [3]. tostring () + ":" + schematable. rows [I]. itemarray [11]. tostring ());
}
This. listbox2.datasource = SS;
// System. Windows. Forms. MessageBox. Show (tablenames );
DB. Close ();
-----------------------------------------
DB type
Public oledbconnection oleconnection;
Public dB (string connstring)
{
Try
{
Connstring = "provider = Microsoft. Jet. oledb.4.0; Data Source =" + connstring;
Oleconnection = new oledbconnection (connstring );
Oleconnection. open ();
// System. Windows. Forms. MessageBox. Show ("the database is connected! ");
}
Catch
{
System. Windows. Forms. MessageBox. Show ("database connection error! ");
}
}
Public void close ()
{
Oleconnection. Close ();
// System. Windows. Forms. MessageBox. Show ("the database is disabled! ");
}
-----------------------------------
Reference 1:
How to read the table structure information of the Access Database
Http://www.why100000.com/Htmls/tabAspNet213.htm
Reference 2:
C # Use getoledbschematable to retrieve Architecture Information (tables, columns, primary keys, etc)
Http://www.cnitblog.com/yhf119/archive/2008/01/16/38926.html

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.