what's wrong in written mention code pls guide us.
protected void Unnamed_Click(object sender, EventArgs e)
{
int userId = 0;
string ConString= ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
using (SqlConnection con = new SqlConnection(ConString))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO Tbl_Profile VALUES(@username,@passwords,@EMail_ID)"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@username", txtUsername.Text.Trim());
cmd.Parameters.AddWithValue("@passwords", txtPassword.Text.Trim());
cmd.Parameters.AddWithValue("@EMail_ID", txtEmail.Text.Trim());
cmd.Connection = con;
con.Open();
userId = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
}
}
string message = string.Empty;
switch (userId)
{
case -1:
message = "Username already exists.\\nPlease choose a different username.";
break;
case -2:
message = "Supplied email address has already been used.";
break;
default:
this.SendActivationEmail(userId);
Response.Redirect("~/Activation.aspx");
break;
}
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + message + "');", true);
}
}