标题:高手帮忙看下,asp.net写的.数据库为什么不能更新?
取消只看楼主
tc1937
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-4-27
结帖率:0
已结贴  问题点数:20 回复次数:0 
高手帮忙看下,asp.net写的.数据库为什么不能更新?
protected void Submit_Click(object sender, EventArgs e)
    {
        SqlConnection cn = new SqlConnection("server=localhost ;uid=sa;pwd=sa;database=HotelManagement");
        string n = "select top (1) UserID from Login order by UserID desc";
        SqlCommand cmd = new SqlCommand(n, cn);
        cn.Open();
        SqlDataReader sdr = cmd.ExecuteReader();
        sdr.Read();
        int a = (int)sdr["UserID"];
        int b;
        b = a + 1;
        string s = "";
        if (RadioButton1.Checked)
            s = "男";
        else if (RadioButton2.Checked)
            s = "女";
        
        SqlCommand cm = new SqlCommand("insert into Customers(UserID,CName,CAge,CSex,CPhone) values('" + b + "','" + this.TextBox1.Text + "','" + this.TextBox4.Text + "','" + s + "','" + this.TextBox8.Text + "'", cn);
        SqlDataAdapter da = new SqlDataAdapter(cm);
        
      
    }
搜索更多相关主题的帖子: localhost 数据库 
2011-04-27 15:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-338117-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.402540 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved