c#如何判断mysql表明是否存在。。。sql同理

xiaoxiao2021-02-28  9

string connStr = "Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword"; string cmdStr = "select * from information_schema.TABLES where Table_NAME ='tbl_1_1_1_MeasurementData'"; using (MySqlConnection conn = new MySqlConnection(connStr)) { MySqlCommand cmd = new MySqlCommand(cmdStr, conn); conn.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { int count = reader.GetInt32(0); if (count == 0) { MessageBox.Show("该表不存在!"); } else if (count == 1) { MessageBox.Show("该表存在!"); } } }
转载请注明原文地址: https://www.6miu.com/read-2250265.html

最新回复(0)