When you use msysobjects it generates and error the using the if
object ID would not work in this case.
so I used a work around of using the count statement...
Select count (*) from demographs, this works when I use the
try ..catch so that it looks something like this

cmd.CommandText = "Select count(*) from Demographs";

         // string datcount = "drop table demographs";


        if (conn.State == ConnectionState.Closed)
            conn.Open();
        try
        {
            cmd.CommandText = "Select count(*) from Demographs";
           cmd.ExecuteNonQuery();

           cmd.CommandText = "drop table demographs";
           cmd.ExecuteNonQuery();

        }
       catch
        {
            cmd.CommandText = "Create table Demographs (RFnumber
char(50),VisitDate char(80),StudyID int,plasmarequest int,plasmastored
int, WBdatecollected char(50), timeWB int)";
            cmd.ExecuteNonQuery();
        }
That seems to work.

On Oct 13, 6:43 am, lauhw <[email protected]> wrote:
> The easiest way is to execute a select command on the table.
>
> If the following command raise exception upon execution, means the
> table does not exist.
>
>     cmd.CommandText = "select top 1 * from demographs";
>
> The hard way is to query the database schema. Try to google
> "OleDbConnection.GetOleDbSchemaTable".
>
> To drop the table, you will have to execute the command below:
>
>     drop table demographs
>
> Do not include the "IF OBJECT_ID(....".
>
> If the database can be anything else, why not use SQLCE which is a
> client database and server is not required?

Reply via email to