tags:

views:

48

answers:

2

Why is this not working for me? What is wrong with my code below? I am trying to read a stored proc and applying values to labels. Getting error that say "Incorrect syntax near CareerInner".........

   Private Sub LoadData()

    ' Define data objects
    Dim conn As SqlConnection
    Dim Comm As SqlCommand
    Dim reader As SqlDataReader

    conn = New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)


    Comm = New SqlCommand( _
        ("CareersInner"), conn)

    Comm.Parameters.AddWithValue("@ID", Request.QueryString("ID"))

    conn.Open()

    reader = Comm.ExecuteReader()

    If reader.Read() Then

        lbltitle.Text = reader.Item("title").ToString
        lbldescription.Text = reader.Item("description").ToString

    End If

     reader.Close()

     conn.Close()

End Sub

Edit: My Stored Proc

ALTER PROCEDURE [dbo].[CareersInner]



    @ID varchar(10)

     AS
  BEGIN

 SET NOCOUNT ON;


  SELECT * FROM Careers WHERE ID = @ID 

   END
+3  A: 
 Comm.CommandType = CommandType.StoredProcedure;
Alex Reitbort
Thank you very much!!!
Etienne
A: 

May be try something like:

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter(("@ID", Request.QueryString("ID"));

Did you try tracing with SQL Profiler?

NinethSense