我这里现在有一个修改功能的代码请大家帮我看一下哪里错误谢谢啊,我现在运行不了?
try
{
this.dataSet11.Clear();
//this.sqlDataAdapter1.UpdateCommand.CommandText="update admin set username='"+this.comboBox1.Text.Trim()+"',password='"+this.comboBox2.Text.Trim()+"'from admin where id='"+this.comboBox3+"'";
string StrSQL="update admin set username='"+this.textBox1.Text.Trim()+"',password='"+this.textBox2.Text.Trim()+"'from admin where id='"+this.textBox3+"'";
this.sqlDataAdapter1.SelectCommand.CommandText=StrSQL;
this.sqlDataAdapter1.UpdateCommand.Connection=this.sqlConnection1;
//打开数据库连接
this.sqlConnection1.Open();
//执行SQL命令
this.sqlDataAdapter1.UpdateCommand.ExecuteNonQuery();
//关闭连接
this.sqlConnection1.Close();
//更新数据库
this.sqlDataAdapter1.Fill(this.dataSet11,"admin");
this.dataGrid1.DataSource=this.dataSet11;
}
catch(Exception Err)
{
MessageBox.Show("查询数据库记录操作失败:"+Err.Message,"信息提示",
MessageBoxButtons.OK,MessageBoxIcon.Information);
//如果打开了连接,则关闭它
if(this.sqlConnection1.State==ConnectionState.Open)
{
this.sqlConnection1.Close();
}
}