QQ:416246137 欢迎大家交流
首先是load方法:
private void jinhuojilu_Load(object sender, System.EventArgs e)
{
Form2 for2=new Form2();
string quanju=for2.xuanfang();
this.label1.Text=for2.xuanfang();
conn= new SqlConnection("Server=127.0.0.1;database=lingding;user id=sa;password=198223");//---连接
dataA = new SqlDataAdapter("select * from jinhuojilu where 产品名称='"+quanju+"'",conn);
dataA.Fill(ds);
this.dataGrid1.DataSource=ds.Tables[0];
}
然后是删除按钮方法:
dataGrid1.CurrentCell = new DataGridCell(dataGrid1.CurrentRowIndex,0); //使当前dataGrid的单元格为选择行的第一列(ID)
string UserCoding = dataGrid1[this.dataGrid1.CurrentCell].ToString();
Form2 for2=new Form2();
string quanju=for2.xuanfang();
dataA = new SqlDataAdapter("delete jinhuojilu where id='"+UserCoding+"'",conn);
dataA.Fill(ds);
代码就是这样,可是就是不行.