数据库不显示信息

时间:2014-09-22 14:25:43

标签: asp.net

没有错误,但我不确定为什么我的数据库没有显示我的信息。有人可以帮忙吗?

Registration.cs

    protected void Reg_Submit_Click(object sender, EventArgs e)
    {
        string formUserNameID = username.ToString();
        string formEmailID = email.ToString();
        string formPasswordID = password.ToString();

        NotLoggedIn displayDataObj = new NotLoggedIn();
        displayDataObj.InsertRegName(formUserNameID, formEmailID, formPasswordID);

< --------------------------------------------- ----------------------------------------------> NotLoggedIn.cs

    public virtual void InsertRegName(string formUserNameID, string formEmailID, string formPasswordID)
    {
        TextBox userName = new TextBox();
        TextBox email = new TextBox();
        TextBox password = new TextBox();

        formUserNameID = userName.Text;
        formEmailID = email.Text;
        formPasswordID = password.Text;

        try
        {

            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString); //creates sql connection object  to the database via connection string 
            conn.Open(); //Open Connection
            string insertUserQuery = "insert into users (UserName,Email,Password) values (@Uname, @email, @password)";
            SqlCommand com = new SqlCommand(insertUserQuery, conn); //COmmand that imputs query and allows connection
            com.Parameters.AddWithValue("@Uname", formUserNameID);
            com.Parameters.AddWithValue("@email", formEmailID);
            com.Parameters.AddWithValue("@password", formPasswordID);

            com.ExecuteNonQuery();

            HttpContext.Current.Response.Redirect("Manager.aspx");
            HttpContext.Current.Response.Write("Registration is successful.");

            conn.Close(); //Close Connection 

        }
        catch (Exception regEx)
        {
           HttpContext.Current.Response.Write("Error" + regEx.ToString());

        }

    }

0 个答案:

没有答案