I have a set of stored procedures that I use to populate ASP.NET CheckBoxList. When executing this procedure from code in the form {CALL ProcedureName (params); } with the type set as the stored procedure, I only return a partial result (that is, many columns from the actual result are missing.)
If I copy a CommandText from the query (using a breakpoint to get the exact text) and run it directly in Navicat (or any other MySQL GUI), I get all the expected columns.
Here is the code that does not work:
using (OdbcCommand command = OdbcConnection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "{ " + string.Format(StoredProcedureCall, foundationId, fpids, "", "", "NULL", "2001/01/02", "2001/01/01", "*") + " }"; using (OdbcDataReader reader = command.ExecuteReader()) { for (int i = 0; i < reader.FieldCount; i++) { columns.Add(reader.GetName(i)); } } }
If I changed the code to the following, however, it starts working (just adding another):
using (OdbcConnection) using (OdbcCommand command = OdbcConnection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "{ " + string.Format(StoredProcedureCall, foundationId, fpids, "", "", "NULL", "2001/01/02", "2001/01/01", "*") + " }"; using (OdbcDataReader reader = command.ExecuteReader()) { for (int i = 0; i < reader.FieldCount; i++) { columns.Add(reader.GetName(i)); } } }
What's going on here?
For reference: OdbcConnection property:
public static OdbcConnection OdbcConnection { get {