Pergunta

I am connecting to a Sybase 9 database to retrieve data. I can query the database without issue using ODBC connections but I am having an issue calling stored procedures. The procedure was written probably 6-7 years ago. This is what I have to execute the stored procedure.

OdbcCommand itemWeightAve = conn.CreateCommand();
itemWeightAve.CommandText = "ComputeLastCost";
itemWeightAve.CommandType = CommandType.StoredProcedure;
itemWeightAve.Parameters.AddWithValue("@OwnerId", "BananaHammock");//company number
itemWeightAve.Parameters.AddWithValue("@InventoryId", InventoryNumberHere);//inventory id from query results
itemWeightAve.Parameters.AddWithValue("@EndDate", EndDateHere);//end date from query results
OdbcDataReader itemAveReader = itemWeightAve.ExecuteReader();

I am not very familiar with Sybase or ODBC and the version these guys are using is extremely old and is no longer officially supported. Upgrading the Sybase database is out of the question. The error I get when attempting to execute this command is...

ERROR [42S02] [Sybase][ODBC Driver][Adaptive Server Anywhere]

Procedure 'ComputeLastCost' not found

I know that the procedure exists, it is typed correctly, and that the parameter names exist and are typed correctly. Does anyone have any tips/hints/suggestions for what I'm doing wrong here?

Foi útil?

Solução

Turned the comment into an answer...

What is the default database of the login that you are using?

Is the stored procedure in the same database?

If not, you need to prefix your procedure name with the database name "sharedDB.ComputeLastCost".

You can check this by logging in with the same user/password through isql and try and exec it by hand. if you have to do a use database (ie. use database sharedDB) before you execute it, you need to put the db name in front.

You can also change your default database for the user. Either way should work.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top