Link to home
Start Free TrialLog in
Avatar of Anushart
AnushartFlag for United States of America

asked on

Could not find the stored procedure

Could not find stored procedure 'EXEC SP_DATAEVAL1 @carrierid, @plugres'." blow is the code I wote the code
        plugres = ds.Tables(1).Rows(0).Item("Plug_Resistor").ToString 'From my app
        carrierid = ds.Tables(1).Rows(0).Item("CarrierNumber").ToString()'From my app
        Dim SQLCon As New SqlClient.SqlConnection
        SQLCon.ConnectionString = strConnection
        da = New SqlDataAdapter("EXEC SP_DATAEVAL1 @carrierid, @plugres", SQLCon)
        da.SelectCommand.CommandType = CommandType.StoredProcedure

        Dim ds1 As New DataSet
        SQLCon.Open()
        da.Fill(ds1)
        SQLCon.Close()
....................................................

SP_DATAEVAL1 is my stored procedure  @carrierid, @plugres are my parameters ...please check my code & tell me if i passed them correctly & why this error cannot find stored procedure is..
Thank you
Avatar of ptjcb
ptjcb
Flag of United States of America image

Is the sp_dataeval1 procedure in the same database as the strConnection database catalog?

For example, if the strConnection opens a connection to database1, but sp_dataeval1 is in database2, then it will not find it.
Avatar of Bob Learned
Try this:

da = New SqlDataAdapter("SP_DATAEVAL1", SQLCon)
da.SelectCommand.CommandType = CommandType.StoredProcedure
da.SelectCommand.Parameters.AddWithValue("@carrierid", carrierid)
da.SelectCommand.Parameters.AddWithValue("@plugres", plugres )

Bob
Avatar of Anushart

ASKER

I checked the connection string and its correct(to database where my SP is there)
I even changed my SP name and tried this code but it still says cannot find Stored procedure

 Dim SQLCon As New SqlClient.SqlConnection
        SQLCon.ConnectionString = strConnection
        da = New SqlDataAdapter("EXEC DATAEVAL1_YESP", SQLCon)
        da.SelectCommand.CommandType = CommandType.StoredProcedure
        da.SelectCommand.Parameters.AddWithValue("@carrierid", carrierid)
        da.SelectCommand.Parameters.AddWithValue("@@plugresistor", plugres)
        Dim ds12 As New DataSet
        SQLCon.Open()
        da.Fill(ds12)
        SQLCon.Close()
Can you tell me if I have coded anything wrong?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks learnedone it worked!!