我想做个窗口 里面的一个按键(就叫按键1吧) 只要点一下就能清空数据库(数据库名也就叫DB吧)中的几个指定表(TB1、TB2、TB3)中的内容。该怎么编写按键的单击事件呢?
6 个解决方案
#1
delete from TB1 where...
#2
var connection = new SqlConnection("...");
new SqlCommand("truncate table TB1", connection).ExecuteNonQuery();
new SqlCommand("truncate table TB1", connection).ExecuteNonQuery();
#3
http://topic.csdn.net/u/20110504/14/3c0a657a-139a-4036-ab0f-87248498f078.html
上面有链接数据库的函数 直接调用
delete from TB1
delete from TB2
delete from TB3
#4
#5
SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=DB;Persist Security Info=True;User ID=数据库登录名;Password=数据库登录密码");
string sql ="delete from TB1";
SqlCommand comm = new SqlCommand(sql, conn);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
删除TB2和TB3类似
string sql ="delete from TB1";
SqlCommand comm = new SqlCommand(sql, conn);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
删除TB2和TB3类似
#6
+1.
#1
delete from TB1 where...
#2
var connection = new SqlConnection("...");
new SqlCommand("truncate table TB1", connection).ExecuteNonQuery();
new SqlCommand("truncate table TB1", connection).ExecuteNonQuery();
#3
http://topic.csdn.net/u/20110504/14/3c0a657a-139a-4036-ab0f-87248498f078.html
上面有链接数据库的函数 直接调用
delete from TB1
delete from TB2
delete from TB3
#4
#5
SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=DB;Persist Security Info=True;User ID=数据库登录名;Password=数据库登录密码");
string sql ="delete from TB1";
SqlCommand comm = new SqlCommand(sql, conn);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
删除TB2和TB3类似
string sql ="delete from TB1";
SqlCommand comm = new SqlCommand(sql, conn);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
删除TB2和TB3类似
#6
+1.