I am using getschema and simply trying to get names of tables within database data1.dbc. I have looked at the returned schmema info with the debugger and with the following code and can't see table names (which I know are in database). Have I used GetSchema correctly or am I not looking in the right place? Thanks!

string strCon = @"Provider=VFPOLEDB;Data Source=c:\users\me\My Documents\data1.dbc"; // this dbc exists
            OleDbConnection cn = new OleDbConnection(strCon);

            // Open Connection
            cn.Open();

            //DataTable schemaInfo = cn.GetSchema(); // available schemas
          
            //foreach (DataRow row in schemaInfo.Rows)
            //{
            //   string schema = (string)row[0];

            //   DataTable t = cn.GetSchema(schema);
            //   Form f = new ShowDataForm(t, schema);
            //   f.ShowDialog();
            //}

public class ShowDataForm : Form
{
    public ShowDataForm(DataTable tbl, string caption)
    {
        this.dgv = new System.Windows.Forms.DataGridView();
        this.dgv.Location = new System.Drawing.Point(0, 0);
        this.dgv.Dock = DockStyle.Fill;
        this.dgv.DataSource = tbl;
        this.Text = caption;
        this.Controls.Add(this.dgv);
        this.ClientSize = new System.Drawing.Size(1024, 768);
    }
    private System.Windows.Forms.DataGridView dgv;
}

When you cn.GetSchema() you are retrieving the metadata info, not the tables info. The metadata info will give you the collection names you can retrieve using cm.GetSchema(CollectionName). You must enumerate the results in order to obtain the specific collection name for the tables info.

Please read here and there for the GetSchema() common and specifics.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.