“could not find stored procedure”

后端 未结 10 1169
死守一世寂寞
死守一世寂寞 2020-12-20 11:43

I am maintaining a classic ASP website that has a SQL Server 2005 backend. For a small piece of new functionality I wrote a stored procedure to do an insert. This is the o

10条回答
  •  一向
    一向 (楼主)
    2020-12-20 12:10

    There are 2 causes:

    1- store procedure name When you declare store procedure in code make sure you do not exec or execute keyword for example:

    C#

    string sqlstr="sp_getAllcustomers";// right way to declare it.
    
    string sqlstr="execute sp_getAllCustomers";//wrong way and you will get that error message.
    

    From this code:

    MSDBHelp.ExecuteNonQuery(sqlconexec, CommandType.StoredProcedure, sqlexec);

    CommandType.StoreProcedure will look for only store procedure name and ExecuteNonQuery will execute the store procedure behind the scene.

    2- connection string:

    Another cause is the wrong connection string. Look inside the connection string and make sure you have the connection especially the database name and so on.

提交回复
热议问题