Re: Stupid Question about Tables
Posted by: Peter Brawley
Date: November 24, 2006 10:05AM

You'd be better off using Connector/NET 5.

Here's one way:
public Int32 TableExists( string db, string table, MySqlConnection conn ) {
  object obj = null;
  MySqlCommand cmd = new MySqlCommand();
  try {
    cmd.CommandText = "SELECT COUNT(*) FROM information_schema.tables " +
                      "WHERE table_schema = '" + db + "' " 
                      "AND table_name = '" + table + "'";
    cmd.Connection = conn;
    obj = cmd.ExecuteScalar();
  }
  catch ( MySqlException ex ) {
    MessageBox.Show( ex.Message + Environment.NewLine + ex.StackTrace.ToString(); );
  }
  finally {
    cmd.Dispose();
  }
  return Int32.Parse( obj.ToString() );
}

PB

Options: ReplyQuote


Subject
Written By
Posted
November 24, 2006 07:49AM
Re: Stupid Question about Tables
November 24, 2006 10:05AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.