Checking and creating a View within MySQL via C# -
I should be able to see if a view is already present in my MySQL database and if it is one C#. I could actually do a bit with a little help and in the right direction - if possible.
You can use information_schema to query if a different object, see in your case, exists is. My example code snippet has C # below.
string conn = @ "data source = myserverName; initial catalog = myCatalogName; coordinated security = true"; String cmdStr = "count_schema.views to count (*) where table_schema = 'mySchemaName' and table_name = 'MyViewName'"; (MySqlConnection conn = New MySqlConnection (conn)) using {MySqlCommand cmd = new MySqlCommand (cmdStr, conn); conn.Open (); MySqlDataReader Reader = cmd.ExecuteReader (); While (reader.Read ()) {int count = reader.GetInt32 (0); If (calculation == 0) {MessageBox.Show ("see does not exist!"); MySqlCommand command = New MySqlCommand ("Choose my image from MyTable *;", conn) command.ExecuteNonQuery (); } And if (calculation == 1) {MessageBox.Show ("see exists!"); } Conn.Close (); }}
Comments
Post a Comment