标题:用户代码未处理 SqlException
只看楼主
wxxcrystal
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-5-5
结帖率:50%
已结贴  问题点数:20 回复次数:1 
用户代码未处理 SqlException
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Threading;

namespace WebApplication1
{
    public partial class 户主注册 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string str = ConfigurationManager.ConnectionStrings["apartmentConnectionString"].ConnectionString;
            SqlConnection con = new SqlConnection(str);
            SqlCommand sqlcommand = new SqlCommand();
            sqlcommand.Connection = con;


             = "insert into huzhu(hzname,unit,layer,number,hzpassword,) values(@idd,@un,@ly,@num,@hzpass)";
            sqlcommand.Parameters.AddWithValue("@idd", TextBox1.Text);
            sqlcommand.Parameters.AddWithValue("@un", TextBox2.Text);
            sqlcommand.Parameters.AddWithValue("@ly", TextBox3.Text);
            sqlcommand.Parameters.AddWithValue("@num", TextBox4.Text);
            sqlcommand.Parameters.AddWithValue("@hzpass", TextBox5.Text);


            try
            {
                con.Open();

                sqlcommand.ExecuteNonQuery();
                Label1.Text = " 注册成功";
               
                Response.Redirect("户主登录.aspx");
            }

            finally
            {
                sqlcommand = null;
                con.Close();
                con = null;
            }
        }
    }
}
搜索更多相关主题的帖子: public 用户 
2014-05-05 22:11
asdfv63
Rank: 3Rank: 3
等 级:论坛游侠
威 望:5
帖 子:38
专家分:142
注 册:2013-4-15
得分:14 
这个貌似是没带catch么。。
2014-05-06 08:14



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




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

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