코드를 실행하려고 할 때 문제가 있습니다. 아래 코드와 같이 'PASSWORD =' '를 설정하면 모든 것이 잘 실행됩니다.SQL 문제 - NULL 값을 읽지 않습니다.
public int ClearEmployeePasswordById(Employee p)
{
int result = -1;
try
{
string sql = "UPDATE EMPLOYEE SET " +
"PASSWORD=''" +
"WHERE Employee_Id=" + p.EmployeeId;
Common.logToFile("PosNet.Data.Sybase.cs", "ClearEmployeePasswordById", sql);
string r = ExecuteNonQuery(sql);
if (!string.IsNullOrEmpty(r))
throw new Exception(r);
result = 1;
InsertAuditLog();
}
catch (Exception ex)
{
Common.logErrorToFile("PosNet.Data.Sybase.cs", "ClearEmployeePasswordById", ex.Message);
//throw ex;
}
return result;
}
하지만이 SQL 내 기능에 PASSWORD=NULL
을 변경할 때, 그것은 오류 "Reset Password Failed"
을 보여줍니다. 빈 문자열은 읽지 만 NULL 값은 읽지 않습니다. 왜 그렇게됩니까?
private void btnPasswordReset_Click(object sender, EventArgs e)
{
try
{
string employeeWithoutQuote = lblEmployeeId.Text.Substring(1, 10);
int employeeId = int.Parse(employeeWithoutQuote);
Employee employee = MF.BC.DA.GetEmployeeByBarcode(employeeId);
if (MF.BC.DA.ClearEmployeePasswordById(employee) != 1)
{
throw new Exception("Reset Password Failed");
}
else
{
MessageBox.Show("Reset Password Success");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
디버깅을하셨습니까? 또한 SP 코드를 추가해야합니다. –
던져진 예외는 무엇입니까? –
실제로 작성한 SQL을 보면'SET PASWORD = NULLWHERE Employee_Id = ...'로 표시됩니다. –