I gote exception "Error converting data type nvarchar to int." on cmd.ExecuteNonQuery();
when I run following code.
{
con.Open();
{
string OLdpassword = txtOldPassword.Text;
if (OLdpassword == txtOldPassword.Text)
{
if (txtNewPassword.Text == txtConfirmPassword.Text)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "UpdatePassword";
cmd.Parameters.AddWithValue("@user_id",Convert.ToString(Session["user_id"]));
cmd.Parameters.AddWithValue("@user_password", txtOldPassword.Text);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
lblmsg.Text = "Password updated successfully";
}
else
{
lblmsg.Text = "Execution error";
}
}
else
{
lblmsg.Text = "Password miss match";
}
}
else
{
lblmsg.Text = "Old password is incorrect";
}
}
con.Close();
clear();
}
catch (Exception ex)
{
}