值不会更新到asp.net中的mysql数据库 [英] values not updating into mysql datbase in asp.net

查看:62
本文介绍了值不会更新到asp.net中的mysql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MySqlConnection con = new MySqlConnection();

        MySqlCommand com = new MySqlCommand();

        MySqlDataReader dr;

        con = new MySqlConnection(ConfigurationManager.ConnectionStrings["netConnectionString"].ToString());
        con.Open();
        com = new MySqlCommand("select full_name,email,age,user_name,country,password,education,about,interest from users where user_name='" + Session["user"] + "'", con);
        dr = com.ExecuteReader();
        if (dr.Read())
        {
            
            TextBox5.Text = dr[0].ToString();
            TextBox4.Text = dr[1].ToString();
            TextBox6.Text = dr[2].ToString();
            TextBox7.Text = dr[3].ToString();
            TextBox8.Text = dr[4].ToString();
            TextBox9.Text = dr[5].ToString();
            TextBox1.Text = dr[6].ToString();
            TextBox2.Text = dr[7].ToString();
            TextBox3.Text = dr[8].ToString();
            
            
        }

    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        MySqlConnection con = new MySqlConnection();
        string str = ConfigurationManager.ConnectionStrings["netConnectionString"].ConnectionString;
        con.ConnectionString = str;
        con.Open();
        if (con.State.ToString() == "Open")
        {


            MySqlCommand cmd = new MySqlCommand("UPDATE users SET email=@b,age=@c,user_name=@d,country=@e,password=@f, education=@g,about=@h,interest=@i WHERE user_name=@userName", con);
            
            cmd.Parameters.AddWithValue("@b", TextBox4.Text);
            cmd.Parameters.AddWithValue("@c", TextBox6.Text);
            cmd.Parameters.AddWithValue("@d", TextBox7.Text);
            cmd.Parameters.AddWithValue("@e", TextBox8.Text);
            cmd.Parameters.AddWithValue("@f", TextBox9.Text);
            cmd.Parameters.AddWithValue("@g", TextBox1.Text);
            cmd.Parameters.AddWithValue("@h", TextBox2.Text);
            cmd.Parameters.AddWithValue("@i", TextBox3.Text);
            cmd.Parameters.AddWithValue("@userName", Session["user"].ToString());
            cmd.ExecuteNonQuery();
            TextBox1.Visible = false;
            TextBox2.Visible = false;
            TextBox3.Visible = false;
            Label5.Text = "Well done profile updated!!";
            con.Close();



此代码显示值但不将新值更新到数据库中帮助我使用此编码!!


this code is showing the values but not updating the new values into database help me with this coding!!

推荐答案

请分享输出错误。


这篇关于值不会更新到asp.net中的mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆