本帖最后由 xgr 于 2013-3-2 10:32 编辑
如利用下列方法可以取得ACCESS数据库的架构信息
-
- #region lv1点击时把数据库的表列入到Lv2
- private void listView1_Click(object sender, EventArgs e)
- {
- string filePath = listView1.FocusedItem.SubItems[3].Text;
- listView2.Items.Clear();
- OleDbConnection Connection = null;
- string tableName = "";
- try
- {
- Connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath);
- Connection.Open();
- System.Data.DataTable schemaTable = Connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
- int i = 0;
- foreach (DataRow dr in schemaTable.Rows)
- {
- //表名
- tableName = dr["TABLE_NAME"].ToString();
- // formName = tableName;
- //创建时间
- string tableCreatTime = dr["DATE_CREATED"].ToString();
- //修改时间
- string tableEditTime = dr["DATE_MODIFIED"].ToString();
- ListViewItem lv = new ListViewItem(i++.ToString());
-
- lv.SubItems.Add(tableName);
- lv.SubItems.Add(tableCreatTime);
- lv.SubItems.Add(tableEditTime);
- lv.SubItems.Add(filePath);
- listView2.Items.Add(lv);
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- finally
- {
- Connection.Close();
- }
- }
- #endregion
问题是是否可以修改架构信息,比如表名称,表说明?
或是在创建表时就添加说明可修改之类。
|