Daniel Rabinovits

Daniel Rabinovits

  • NA
  • 34
  • 7.7k

ExecuteReader: CommandText property has not been initialized

Jan 31 2020 10:15 AM
Trying to execute a stored procedure in Oracle and import the data into a dataset.
I keep getting ExecuteReader: CommandText property has not been initialized error.
I am not using a DataReader.  Why is this poping up? 
 
My code is as follows: 
 
var odbcCommand = conn.CreateCommand();
OdbcParameter ODBCParameter1 = new OdbcParameter("@FROMDATE", OdbcType.VarChar, 30);
ODBCParameter1.Value = "01/28/2020";
OdbcParameter ODBCParameter2= new OdbcParameter("@TODATE", OdbcType.VarChar, 30);
ODBCParameter2.Value = "01/29/2020";
OdbcCommand ODBCCommand = new OdbcCommand("getReport", conn);
odbcCommand.CommandType = CommandType.StoredProcedure;
odbcCommand.Parameters.Add(ODBCParameter1);
odbcCommand.Parameters.Add(ODBCParameter2);
OdbcDataAdapter da = new OdbcDataAdapter(odbcCommand);
conn.Open();
DataSet ds = new DataSet();
da.Fill (ds);

Answers (1)