C#怎么写删除数据库代码?
比如我要通过textbox1来输入姓名,点击button按钮,请问要如何写删除代码?
private void button1_Click(object sender, EventArgs e) { string connectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\StudentDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; SqlConnection con = new SqlConnection(); con.ConnectionString = connectionString; string cmdText = "delete 数据库表名 where 姓名='"+this.textbox.text+"'"; SqlCommand cmd = new SqlCommand(cmdText, con); con.Open(); cmd.ExecuteNonQuery(); }