Hello Everyone My code is as follows....
protected void Button4_Click(object sender, EventArgs e)
{
string strpassword = Encryptdata(TextBox5.Text);
SqlConnection conn = new SqlConnection();
conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["leave"].ConnectionString;
conn.Open();
SqlCommand cmd = new SqlCommand("insert into emp_details VALUES('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + strpassword + "','" + DropDownList1.SelectedValue.ToString() + "','" + TextBox4.Text + "')", conn);
cmd.ExecuteNonQuery();
}
private string Encryptdata(string password)
{
string strmsg = string.Empty;
byte[] encode = new byte[password.Length];
encode = Encoding.UTF8.GetBytes(password);
strmsg = Convert.ToBase64String(encode);
return strmsg;
}
further,in database,type for password field is nvarchar(100).The highlighted line is giving me error if i enter Character such as @ in password,that String or binary data would be truncated. The statement has been terminated.
Why this is so?Any help would be greatly appriciated....