| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1494 人关注过本帖
标题:用户代码未处理SqlException 是什么一回事?(在线等)(紧急)
只看楼主 加入收藏
woodaisn
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2008-6-11
收藏
 问题点数:0 回复次数:1 
用户代码未处理SqlException 是什么一回事?(在线等)(紧急)
protected void Button2_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(@"Data Source=AISN\SQLEXPRESS;AttachDbFilename=D:\4246\data\computer.mdf;Integrated Security=True");
        conn.Open();
        string strsql = "select * from Vuser_Information where Vuser_ID=" + DropDownList1.SelectedValue;
        SqlDataAdapter ad = new SqlDataAdapter(strsql, conn);
        SqlCommandBuilder cmb = new SqlCommandBuilder(ad);
        DataSet ds = new DataSet();
        ad.Fill(ds, "Vuser_Information");
        DataTable dt = ds.Tables["Vuser_Information"];
        DataRow row = dt.NewRow();
        row["Vuser_ID"] = TextBox1.Text;
        row["Vuser_name"] = TextBox2.Text;
        row["Vuser_Sex"] = TextBox3.Text;
        row["Vuser_Address"] = TextBox4.Text;
        row["Vuser_Password"] = TextBox5.Text;
        row["Vuser_Spending"] = TextBox6.Text;
        row["Vuser_Remarks"] = TextBox7.Text;

        dt.Rows.Add(row);
        ad.Update(ds, "Vuser_Information");
        Panel1.Visible = false;
        DropDownList1_content();
        GridView1_content();
    }

这个是也添加按钮.

但是一按这个按钮就提示 "用户代码未处理SqlException    '='附近有错误"
搜索更多相关主题的帖子: SqlException 代码 用户 在线 
2008-06-21 22:41
冰彩虹
Rank: 4
来 自:上海
等 级:贵宾
威 望:14
帖 子:806
专家分:44
注 册:2007-6-28
收藏
得分:0 
protected void Button2_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(@"Data Source=AISN\SQLEXPRESS;AttachDbFilename=D:\4246\data\computer.mdf;Integrated Security=True");
try{
        conn.Open();
        string strsql = "select * from Vuser_Information where Vuser_ID=" + DropDownList1.SelectedValue;
        SqlDataAdapter ad = new SqlDataAdapter(strsql, conn);
        SqlCommandBuilder cmb = new SqlCommandBuilder(ad);
        DataSet ds = new DataSet();
        ad.Fill(ds, "Vuser_Information");
        DataTable dt = ds.Tables["Vuser_Information"];
        DataRow row = dt.NewRow();
        row["Vuser_ID"] = TextBox1.Text;
        row["Vuser_name"] = TextBox2.Text;
        row["Vuser_Sex"] = TextBox3.Text;
        row["Vuser_Address"] = TextBox4.Text;
        row["Vuser_Password"] = TextBox5.Text;
        row["Vuser_Spending"] = TextBox6.Text;
        row["Vuser_Remarks"] = TextBox7.Text;

        dt.Rows.Add(row);
        ad.Update(ds, "Vuser_Information");
        Panel1.Visible = false;
        DropDownList1_content();
        GridView1_content();
catch(Exception ex)
{
   //handler the exception
}
}


你数据表里Vuser_ID是什么类型,不是int类型的话,
string strsql = "select * from Vuser_Information where Vuser_ID= ‘" + DropDownList1.SelectedValue + "'";

Flying without wings
2008-06-22 06:31
快速回复:用户代码未处理SqlException 是什么一回事?(在线等)(紧急)
数据加载中...
 
   



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

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