邪魂 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跳过了异常。如果以上都没有问题,就检查你写入的数据库和你现在打开看的是不是一个数据库。

    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能