我有一个注册页面,我正在保存用户的详细信息。
页面正在处理精细数据,但“完整电子邮件地址”未显示在“@email”列的表格中。
示例:如果我正在保存'cozm02011@gmail.com',则表格中仅显示'cozm02011'。
代码
protected void ceratenewuser_Click(object sender, EventArgs e)
{
String ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(ConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "User_pro";
cmd.Parameters.AddWithValue("@UserName", TextBox1.Text.Trim());
cmd.Parameters.AddWithValue("@Password", TextBox2.Text.Trim());
cmd.Parameters.AddWithValue("@Email", TextBox3.Text.Trim());
cmd.Parameters.AddWithValue("@LastSeen", DateTime.Now);
cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
cmd.Connection = con;
try
{
con.Open();
cmd.ExecuteNonQuery();
Label2.Text = "User Created successfully";
TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4 .Text = "";
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}
this.GridView1.DataBind();
}
商店程序
ALTER PROCEDURE dbo.User_pro
@UserName varchar(20),
@Password varchar(20),
@Email varchar(50),
@LastSeen datetime,
@CreatedDate datetime
AS
INSERT INTO User_tbl (UserName, Password, Email, LastSeen, CreatedDate)
VALUES (@UserName, @Password, @Email, @LastSeen, @CreatedDate)
RETURN
答案 0 :(得分:3)
您绑定了" 确认密码"字段到电子邮件列
cmd.Parameters.AddWithValue("@Email", TextBox3.Text.Trim());
TextBox3用于"确认密码"字段。
答案 1 :(得分:2)
试试这个,
cmd.Parameters.AddWithValue("@Email", TextBox4.Text.Trim());