如题目 代码?
StrSql = "delete QiPuName where 表名 = " + "'" + this.listBox2.Text + "'";
myConnection.Open();
this.myCmd1 = new SqlCommand(StrSql, myConnection);
this.DataSet1.Clear();
string strsql2 = "select * from QiPuName";
this.sqlDataAdapter1 = new SqlDataAdapter(strsql2,myConnection);
this.sqlDataAdapter1.Fillthis.DataSet);
int intNumber2 = myCmd1.ExecuteNonQuery();
this.listBox2.Refresh();
myConnection.Close();
StrSql = "delete QiPuName where 表名 = " + "'" + this.listBox2.Text + "'";
myConnection.Open();
this.myCmd1 = new SqlCommand(StrSql, myConnection);
this.DataSet1.Clear();
string strsql2 = "select * from QiPuName";
this.sqlDataAdapter1 = new SqlDataAdapter(strsql2,myConnection);
this.sqlDataAdapter1.Fillthis.DataSet);
int intNumber2 = myCmd1.ExecuteNonQuery();
this.listBox2.Refresh();
myConnection.Close();
this.listBox2.DataBind();
要重新邦定也可以更新。
listBox没有databind()方法??就是不知道怎么绑定
去掉refresh()不会自动更新?
大家帮忙动手试下?就一两个控件又不麻烦 成功了再说?
谢谢大家了啊 郁闷啊
{
con.Open();
SqlCommand cmd = new SqlCommand("delete from studentDetails where sname='jiajun'", con);
cmd.ExecuteNonQuery();
con.Close();
this.DataBind();
} private void Form1_Load(object sender, EventArgs e)
{
this.DataBind();
}
private void DataBind()
{
DataSet ds=new DataSet ();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select * from studentDetails", con);
sda.Fill(ds, "student");
this.listBox1 .DataSource = ds.Tables["student"];
this.listBox1.DisplayMember = "sname";
}