(不必要的代码已省略,删除功能是一个按钮事件)
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data .SqlClient ;
... ....
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
private 饲料进销存管理系统.DataSet1 dataSet11;
我先用代码一,再用代码二,结果运行都提示系统错误,提示行为: this.sqlDeleteCommand1.ExecuteNonQuery();
代码一:
this.sqlDeleteCommand1.Connection .Open ();
this.sqlDeleteCommand1.CommandText="Delete from 员工信息表 where 姓名 = '" + this.textBox1.Text .Trim () +"'";
this.sqlDeleteCommand1.ExecuteNonQuery();
代码二:
this.sqlDeleteCommand1.Connection .Open ();
this.sqlDeleteCommand1.CommandText="Delete from 员工信息表 where 姓名 = '" + this.textBox1.Text .Trim () +"'";
this.sqlDeleteCommand1.ExecuteNonQuery();
this.dataSet11.Clear();
this.sqlDataAdapter1.Fill(this.dataSet11);
this.sqlDeleteCommand1.Connection.Close();
this.textBox1.Text="";this.textBox2.Text="";
this.textBox3.Text="";this.textBox4.Text="";
大家帮帮我好吗?我在论坛里,在网上找了好多资料,可以都找不出我的代码错在哪里。高手救命!