问题描述
- C#中数据库删除按钮中在下面update语句中显示数据库查询过于复杂
-
string connstr = "Provider=Microsoft.Jet.OleDb.4.0;";
connstr += @"Data Source=GEARCNC.mdb";OleDbConnection tempconn = null; try { if (MessageBox.Show("确定删除这一项吗?", "confirm Message", MessageBoxButtons.OKCancel) == DialogResult.OK) { tempconn = new OleDbConnection(connstr); OleDbDataAdapter GrindingWheelInformationDA = new OleDbDataAdapter("select * from GrindingWheelInformation order by 砂轮名称", tempconn); DataSet ds = new DataSet(); GrindingWheelInformationDA.Fill(ds, "GrindingWheelInformation"); int hang = this.listView1.SelectedIndices[0]; DataRow dr = ds.Tables["GrindingWheelInformation"].Rows[hang]; dr.Delete(); OleDbCommandBuilder builder = new OleDbCommandBuilder(GrindingWheelInformationDA); GrindingWheelInformationDA.Update(ds, "GrindingWheelInformation");//这边报错,提示数据库查询过于复杂 listView1.Items.Remove(listView1.SelectedItems[0]); MessageBox.Show("删除完毕!!!"); } } catch (Exception ex) { MessageBox.Show("请选中一行需要删除的数据!"); } finally { tempconn.Close(); }
解决方案
你得把update这个方法贴出来呀,要不怎么看
解决方案二:
select * from GrindingWheelInformation order by 砂轮名称
这句SQL很简单啊?
时间: 2024-10-03 20:43:24