String or binary data would be truncated. [Resolved]

Posted by Self-Innovator under ASP.NET on 3/31/2012 | Points: 10 | Views : 2377 | Status : [Member] | Replies : 1
Hi...
I've this exception while i am entering user details with password in encrypted format..pls go through...
Pls find solution..
 protected void btnSubmit_Click(object sender, EventArgs e)
{
string Uid = txtUserId.Text.Trim();
//string Pwd = txtPassword.Text.Trim();
//System.Text.ASCIIEncoding encryptPwd = new System.Text.ASCIIEncoding();
//byte[] bpwdArray = encryptPwd.GetBytes(Pwd);
string Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(), "MD5");
string Name = txtName.Text.Trim();
string DesigCode = txtDesigCode.Text.Trim();
string Email = txtEmail.Text.Trim();
string TelNo = txtTelNo.Text.Trim();
string HandPhNo = txtHandPhone.Text.Trim();
string active = ddlActive.SelectedValue;
try
{
SqlConnection cnn = new SqlConnection(Conn);
SqlCommand cmd = new SqlCommand("spAddUserDetails", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Uid", Uid);
cmd.Parameters.AddWithValue("@Pwd", Pwd);
cmd.Parameters.AddWithValue("@Name", Name);
cmd.Parameters.AddWithValue("@DesigCode", DesigCode);
cmd.Parameters.AddWithValue("@Email", Email);
cmd.Parameters.AddWithValue("@TelNo", TelNo);
cmd.Parameters.AddWithValue("@HandPhNo", HandPhNo);
cmd.Parameters.AddWithValue("@active", active);
SqlDataAdapter ada = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ada.Fill(ds);
txtUserId.Text="";
txtPassword.Text = "";
txtName.Text = "";
txtDesigCode.Text = "";
txtEmail.Text = "";
txtTelNo.Text = "";
txtHandPhone.Text = "";
ClientScript.RegisterStartupScript(GetType(), "Message", "<script language='javascript'>alert('Record Inserted Successfully');</script>");
}
catch (Exception ex)
{
ClientScript.RegisterStartupScript(GetType(), "Message", "<script language='javascript'>alert('" + ex.Message.ToString() + "');</script>");
}
finally
{
}
}


Join Hands Change lives
Thanks & Regards
Straight Edge Society



Responses

Posted by: Self-Innovator on: 3/31/2012 [Member] Bronze | Points: 25

Up
0
Down

Resolved
Daattype Od pAssword Changed From VARCHAR(50) to VARBINARY...

Join Hands Change lives
Thanks & Regards
Straight Edge Society

Self-Innovator, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response