I have a web form that is invoked by the current sql user to change his or her own sql password. The code is shown below.
When this executes, it does in fact change that users password, but it also throws the error:
ERROR [Microsoft][SQL Server Native Client 10.0][SQL Server]Cannot alter the login '<user>', because it does not exist or you do not have permission.
Has anyone seen this behavior before, and were you able to eliminate the error? The same command issued via SSMS works also works correctly but does not thow any error.
dbconnect oConnection = new dbconnect();
// change sql password for current user
string strSql = "ALTER LOGIN " + Session["s_user"].ToString().Trim() + " WITH PASSWORD='" + ChangePassword1.NewPassword + "' OLD_PASSWORD='" + ChangePassword1.CurrentPassword + "'";
OdbcCommand oCmd1 = new OdbcCommand(strSql, oConnection.Connection);
PasswordErrorDetails.Text = (oe.Message);