数据表不会更新

时间:2015-05-17 19:30:44

标签: c# sql asp.net

我想更新包含两个文本和一个图像所需文件名的数据库。

问题是图像和文件名更新但标题和正文的其他两个文本值不会受到影响,并且不会更改以前的值。 visual studio也没有遇到任何问题,执行命令的消息表明它执行了命令,但除了图像之外什么都没有改变。

 $(document).ready(function change() {
    "use strict";
     var messages = [
                "text 1",
                "text 2",
                     ], i = 0;
var msg = messages[Math.floor(Math.random()*messages.length)];
$('#comments').html(msg).fadeIn(600).delay(10000).fadeOut(600, change);
      })();

1 个答案:

答案 0 :(得分:0)

我找到了答案,我需要这个代码来包含我的页面加载阅读数据库,所以当我点击更新按钮时它就不会这样做。我的意思是问题在于回发的事情。

 if (!Page.IsPostBack)
        {
            if (Request.QueryString["edit"] != null)
            {


                Panel1.Visible = true;
                SqlConnection con2 = new SqlConnection();
                con2.ConnectionString = GNews.Properties.Settings.Default.connectionstring;
                DataTable dt3 = new DataTable();
                con2.Open();
                SqlDataReader myReader = null;
                SqlCommand myCommand = new SqlCommand("select * from loadpost_view where Postid=" + Request.QueryString["edit"].ToString() + "", con2);
                myReader = myCommand.ExecuteReader();



                while (myReader.Read())
                {
                    title_txt.Text = myReader["Title"].ToString();
                    bodytxt.Text = myReader["Body"].ToString();
                }
                con2.Close();
            }
        }
相关问题