邪魂 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 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler