C#中对数据库进行修改,值为listview中自己编辑的东西,可是源数据库中没跟新

之前已经将数据库中的表格显示在listview中了,下面是代码

string connstr = "Provider=Microsoft.Jet.OleDb.4.0;";
connstr += @"Data Source=D:\Merger20150208_caohuan\GEARCNC.mdb";//创建连接对象

        OleDbConnection tempconn = new OleDbConnection(connstr);

        OleDbDataAdapter GrindingWheelInformationDA = new OleDbDataAdapter("select * from GrindingWheelInformation order by 砂轮名称", tempconn);
        DataSet ds = new DataSet();
        GrindingWheelInformationDA.Fill(ds, "GrindingWheelInformation");
        DataRow dr = ds.Tables["GrindingWheelInformation"].Rows[0];
        //dr["砂轮名称"]=l              //这里应该怎么写


        OleDbCommandBuilder builder = new OleDbCommandBuilder(GrindingWheelInformationDA);
        GrindingWheelInformationDA.Update(ds, "GrindingWheelInformation");

1个回答

直接写
OleDbCommand cmd = new OleDbCommand("update tablename set 字段=值 where id = xxx", tempconn);
cmd.Executescalar();

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐