• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

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
0
Anushart
Asked:
Anushart
  • 2
  • 2
1 Solution
 
ptjcbCommented:
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.
0
 
Bob LearnedCommented:
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
0
 
AnushartAuthor Commented:
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?
0
 
Bob LearnedCommented:
No, take the EXEC out of the name, and you have two @@ in the parameter name for plusregistor.

Bob
0
 
AnushartAuthor Commented:
Thanks learnedone it worked!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now