User1817555867 posted
I'm having a problem calling a stored procedure in a sybase database. It keeps telling me that the parameters are not being supplied even though I am including them in my code. Here is my code:
public DataSet executeSP(string sp, string nace, string timePeriod)
{
OdbcConnection myconn = new OdbcConnection(sConnStringDB);
myconn.Open();
OdbcCommand cmd = new OdbcCommand();
OdbcDataAdapter da = new OdbcDataAdapter();
DataSet ds = new DataSet();
cmd = new OdbcCommand(sp, myconn);
cmd.CommandType = CommandType.StoredProcedure;
OdbcParameter myParm1 = cmd.Parameters.Add("@NACECode", OdbcType.VarChar, 20);
myParm1.Value = nace;
OdbcParameter myParm2 = cmd.Parameters.Add("@Timeperiod", OdbcType.VarChar, 20);
myParm2.Value = timePeriod;
da.SelectCommand = cmd;
da.Fill(ds);
myconn.Close();
return ds;
}
This is the error I'm getting
ERROR [HY000] [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]Procedure DBA_Indicators_S expects parameter @NACECode, which was not supplied.
ERROR [HY000] [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]Procedure DBA_Indicators_S expects parameter @Timeperiod, which was not supplied.
I'm confident the SP is correct as I can call it from elsewhere passing in parameters and it brings back expected results.
Any help appreciated.