извините, что беспокою вас всех. Я программирую веб-сайт, и я пытаюсь sh пароль, прежде чем сохранить его в базе данных, но я получаю ошибку. Я видел похожие ответы, которые советуют людям использовать ".ToString ()", однако, когда я пытаюсь это сделать, это, кажется, создает больше ошибок. Любая помощь будет принята с благодарностью.
try
{
//hashing attempt
string hashresult = Convert.ToInt32(FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox4.Text.Trim, "SHA1")); //the error is on this line (TextBox4.Text.Trim)
//.ToString()
//end
SqlConnection con = new SqlConnection(strcon);
if (con.State == System.Data.ConnectionState.Closed)
{
//if its closed the program will open it
con.Open();
}
//texbox info to SQL
SqlCommand cmd = new SqlCommand("insert into user_master_tbl(name,email,dob,region,postcode,user_id,password) values(@name,@email,@dob,@region,@postcode,@user_id,@password)", con);
//connecting textbox to the information typed in
cmd.Parameters.AddWithValue("@name", TextBox3.Text.Trim());
cmd.Parameters.AddWithValue("@email", TextBox1.Text.Trim());
cmd.Parameters.AddWithValue("@dob", TextBox2.Text.Trim());
cmd.Parameters.AddWithValue("@region", DropDownList1.SelectedItem.Value);
cmd.Parameters.AddWithValue("@postcode", TextBox6.Text.Trim());
cmd.Parameters.AddWithValue("@user_id", TextBox9.Text.Trim());
cmd.Parameters.AddWithValue("@password", hashresult);
//firing connection to database
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>" + "alert('Account created successfully, please proceed to login to your account');" + "</script>");
}```