1, read the table name:
ArrayList result = new ArrayList (); OleDbConnection myConn = new OleDbConnection (this.ConnectionString); myConn.Open (); OleDbDataAdapter thisAdapter = new OleDbDataAdapter ( "SELECT * FROM Customer", myConn); OleDbCommandBuilder thisBuilder = new OleDbCommandBuilder (thisAdapter); DataSet thisDataSet = new DataSet (); thisAdapter.Fill (thisDataSet, "Customer"); DataTable myTable = thisDataSet.Tables [ "Customer"]; foreach (DataColumn myCol in myTable.Columns) {result.Add (myCol.ColumnName.ToString ());} Myconn.close (); return results;
2, the description of the table:
OleDbConnection oleDbConnection1 = new OleDbConnection (@ "Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" Application.StartupPath "// First.mdb;"); oleDbConnection1.Open (); DataTable schemaTable = oleDbConnection1.GetOleDbSchemaTable (System .Data.oledb.oledbschemaGuid.columns, new object [] {null, null, "student", null});
System.Data.DataRowCollection DRC = Schematable.Rows; Foreach (DATAROW DR IN DRC) {TextBox1.text = DR ["Column_name"] ":" DR ["Description"]. Tostring () "/ r / n "}
3, populate multiple tables
using System.Data; using System.Data.OleDb; OleDbConnection myConn = new OleDbConnection (@ "Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" Application.StartupPath "// First.mdb;"); myConn. Open (); // build the data set dataSet thisDataSet = new dataSet (); // build adapter OleDbDataAdapter studentAdapter = new OleDbDataAdapter ( "SELECT * FROM Student", myConn); OleDbCommandBuilder studentBuilder = new OleDbCommandBuilder (studentAdapter); OleDbDataAdapter teacherAdapter = new OleDbDataAdapter ( "SELECT * FROM Teacher", myConn); OleDbCommandBuilder teacherBuilder = new OleDbCommandBuilder (teacherAdapter); OleDbDataAdapter genearchAdapter = new OleDbDataAdapter ( "SELECT * FROM Genearch", myConn); OleDbCommandBuilder genearchBuilder = new OleDbCommandBuilder (genearchAdapter); // filled studentAdapter .Fill (thisDataSet, "Student"); Teacheradapter.Fill (thisDataSet, "Teacher"); Geneugghadapter.Fill (thisDataSet, "GeneArch"); myconn.close ();