views:

940

answers:

1

I'm trying to pass a null value for the first parameter in the code below, but MySQL complains that

Incorrect number of arguments for PROCEDURE myProc; expected 2, got 1

When I manually call the procedure with the first argument as null, it works, but when EmptyAsNullStartsWith(employeeNumberText.Text) returns null, it complains.

Database db = DatabaseFactory.CreateDatabase(
  ConfigurationManager.AppSettings["dbType"]
);
DbCommand cmd = db.GetStoredProcCommand("staff_listforinquiry");
db.AddeParameter(
  cmd, 
  "in_employeeNumber", 
  DbType.String, 
  EmptyAsNullStartsWith(employeeNumberText.Text)
);
db.AddeParameter(
  cmd, 
  "in_name", 
  DbType.String, 
  EmptyAsNullContains(employeeNameText.Text)
);
+1  A: 

Did you try having EmptyAsNullContains(employeeNameText.Text) return DBNull instead of regular null?

Chris Marisic
It now works, with just a standard null. I suspect something was being cached somewhere.
ProfK