[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • 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

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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