private void button9_Click(object sender, EventArgs e)
{
string id = this.textBox1.Text;
string name = this.textBox2.Text;
string stuId = this.textBox3.Text;
string sql = "update stuInfo set stuName='" + name + "',stuId='" + stuId + "' where uid=" + id + ""; SqlCommand _cmd = new SqlCommand(sql, connect);
_cmd.ExuitNoQuery();
这样来更新
}
{
string id = this.textBox1.Text;
string name = this.textBox2.Text;
string stuId = this.textBox3.Text;
string sql = "update stuInfo set stuName='" + name + "',stuId='" + stuId + "' where uid=" + id + ""; SqlCommand _cmd = new SqlCommand(sql, connect);
_cmd.ExuitNoQuery();
这样来更新
}
{
string id = this.textBox1.Text;
string name = this.textBox2.Text;
string stuId = this.textBox3.Text;
string sql = "update stuInfo set stuName='" + name + "',stuId='" + stuId + "' where uid=" + id + ""; ad.UpdateCommand = new SqlCommand(sql, connect); //ad在这段代码有实例吗?似乎没有。
//何况按此按钮时,你又用table来更新数据表,table根本就没有更改,何来更新?
int k = ad.Update(ds, "New");
}
按你的方式,老实的用SqlCommand对数据库进行更新吧。用table更新数据库适用于直接在绑定的datagridview里面更改数据后更新数据库。
{
string id = this.textBox1.Text;
string name = this.textBox2.Text;
string stuId = this.textBox3.Text;
string sql = "update stuInfo set stuName='" + name + "',stuId='" + stuId + "' where uid=" + id + "";
SqlCommand cmd=new SqlCommand(sql,connect); cmd.ExecuteNonQuery(); }