R
RSH
I am struggling a bit trying to get at all of the Table names in a given
Access database.
I have the code below which should be retrieving the information...i am just
having a bit of trouble displaying the Table names out of the datatable.
Thanks for any assistance you might be able to offer!
Ron
private void browse_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "Access Databases|*.mdb";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
String strFilename;
strFilename = openFileDialog1.FileName;
cnAccess = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=" + strFilename + ";Persist Security Info=False");
cnAccess.Open();
string[] restrictions1 = new string[] { null, null, null, "TABLE" };
System.Data.DataTable DataTable1 = cnAccess.GetSchema();
for (int i = 0; i < DataTable1.Rows.Count; i++)
{
checkedListBox1.Items.Add(DataTable1.Rows[0].Table.Columns[0].ToString());
<----- This is where I need to display the Table names
}
}
}
Access database.
I have the code below which should be retrieving the information...i am just
having a bit of trouble displaying the Table names out of the datatable.
Thanks for any assistance you might be able to offer!
Ron
private void browse_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "Access Databases|*.mdb";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
String strFilename;
strFilename = openFileDialog1.FileName;
cnAccess = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data
Source=" + strFilename + ";Persist Security Info=False");
cnAccess.Open();
string[] restrictions1 = new string[] { null, null, null, "TABLE" };
System.Data.DataTable DataTable1 = cnAccess.GetSchema();
for (int i = 0; i < DataTable1.Rows.Count; i++)
{
checkedListBox1.Items.Add(DataTable1.Rows[0].Table.Columns[0].ToString());
<----- This is where I need to display the Table names
}
}
}