Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

access数据库无法更新,大家帮我看看

雪纷纷  发表于:2011-03-22 15:17:51  
复制

我用asp.net+access做开发,birthrate和comschdate是日期型(短日期格式),其他的代码都没有问题,就是下面的代码再执行时老是无法对数据进行更新,大家帮我看看,问题处在哪里了?

protected void jsxxGridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=|DataDirectory|jsdb.mdb;";

        string upstr="update teacherinfo set teachername='"
            +((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + "',jxdw='"
            +((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim() + "',zhch='"
            +((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim() + "',education='"
            +((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim() + "',degree='"
            +((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim() + "',speciality='"
            +((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString().Trim() + "',sex='"
            +((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[7].Controls[0])).Text.ToString().Trim() + "',birthrate='"
            +Convert.ToDateTime(((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[8].Controls[0])).Text.ToString().Trim()) + "',comschdate='"
            +Convert.ToDateTime(((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[9].Controls[0])).Text.ToString().Trim()) + "',idcard='"
            +((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[10].Controls[0])).Text.ToString().Trim() + "',zhjzhi='"
            +((TextBox)(jsxxGridView1.Rows[e.RowIndex].Cells[11].Controls[0])).Text.ToString().Trim() + "' where teacherid='"
            + jsxxGridView1.DataKeys[e.RowIndex].Value.ToString() + "'";
        OleDbConnection Con = new OleDbConnection(ConStr);
        OleDbCommand upcom = new OleDbCommand(upstr, Con);
        OleDbDataAdapter OleDbdap = new OleDbDataAdapter();
        Con.Open();
        //upcom.ExecuteNonQuery();
        OleDbdap.UpdateCommand = upcom;
        OleDbdap.UpdateCommand.ExecuteNonQuery();
        Con.Close();
        jsxxGridView1.EditIndex = -1;
        bindGridView1();

 

Top
总记录:0篇  页次:0/0 9 1 :