Check existence of a table in MS Access Database RRS feed

  • Question

  • In my Access Database, I have two tables - (1) Control; and (2) Results. I have to delete Results in order to build a new "Results" table with different columns. 

    For information, the way I access table (1) "Control" is as follows:


     OleDbConnection connection = new OleDbConnection();
     connection.ConnectionString = @"path;";

     OleDbDataAdapter adapter2 = new OleDbDataAdapter("SELECT * FROM Control", connection);
      adapter2.Fill(DS1, "Control");

      [Steps to update "Control"


    Thanks to help from you guys, I have learnt to use the following to delete the table. 

    OleDbCommand cmd = new OleDbCommand("DROP TABLE Results", connection);

    Question: I need to first check the existence of the table "Results". Then I read about 

    if (DS1.Tables.Contains("Results")" but it does not seem to work. [It seems that only if I have filled DS1 with "Results", then it works. But the trouble is I don't know whether or not Table "Results" exists [because at times it could have been deleted before I run the program. 

    Thanks for your help. 

    P.S. Also appreciate any tips / pointers as how I can learn the Table related method more systematically. 

    Saturday, May 30, 2015 7:19 AM


All replies