邪魂 2017-11-11 14:37 采纳率: 0%
浏览 712

c# asp.net 对数据库操作不成功

  • protected void submit_Click(object sender, EventArgs e)
    {
    if (text.Text != "")
    {

        if (display.Checked == true)
        {
            string nowTime = DateTime.Now.ToString("yyyy-MM-dd");
            if (check01.Text == "1")
            {
                run.operateData("update notice set text='" + text.Text + "',time='" + nowTime + "',display='1是' where id=" + editID, -1, 0);
                run.operateData("update notice set display='是' where id=" + editID, -1, 0);
                Response.Write("<script>alert('修改成功!');window.location = 'noticeManage.aspx';</script>");
                check01.Text = "0";
            }
            else
            {
                run.operateData("insert into notice (text,time,display) values ('" + text.Text + "','" + nowTime + "','是')", -1, 0);
                Response.Write("<script>alert('添加成功!');window.location = 'noticeManage.aspx';</script>");
            }
    
        }
        else
        {
    
            string nowTime = DateTime.Now.ToString("yyyy-MM-dd");
            if (check01.Text == "1")
            {
                run.operateData("update notice set text='" + text.Text + "',time='" + nowTime + "',display='0否' where id=" + editID, -1, 0);
                run.operateData("update notice set text='" + text.Text + "'" +" where id=" + editID, -1, 0);
                Response.Write("<script>alert('修改成功!');window.location = 'noticeManage.aspx';</script>");
                check01.Text = "0";
            }
            else
            {
                run.operateData("insert into notice (text,time,display) values ('" + text.Text + "','" + nowTime + "','否')", -1, 0);
                Response.Write("<script>alert('添加成功!');window.location = 'noticeManage.aspx';</script>");
            }
        }
    
    }
    else Response.Write("<script>alert('通告内容不能为空!')</script>");
    

    }

oprerateDate是操作数据库,那个update的sql语句 点击按钮后 提示修改成功,但是数据库 内容没有改变,也没有报错

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-11 15:49
    关注

    没有报错首先要看run.operateData这个方法执行了没有,这个方法里的实现代码是什么,有没有try catch跳过了异常。如果以上都没有问题,就检查你写入的数据库和你现在打开看的是不是一个数据库。

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?