2009-10-07 62 views
0

時,爲什麼這個工作不適合我的工作給我嗎?我的代碼在下面有什麼問題?我正在嘗試讀取存儲的proc並將值應用於標籤。獲取錯誤說 「CareerInner附近有語法錯誤」 .........,讀取存儲PROC不傳遞值

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 

編輯: 我的存儲過程

ALTER PROCEDURE [dbo].[CareersInner] 



    @ID varchar(10) 

    AS 
    BEGIN 

SET NOCOUNT ON; 


    SELECT * FROM Careers WHERE ID = @ID 

    END 
+0

你什麼錯誤? – M4N 2009-10-07 10:58:28

+0

System.Data.SqlClient.SqlException = { 「附近有語法錯誤CareersInner'。」} – Etienne 2009-10-07 11:02:01

+0

被命名爲 ' 「CareersInner」' 或 ' 「CareerInner」' 的PROC? – RobS 2009-10-07 11:05:11

回答

3
Comm.CommandType = CommandType.StoredProcedure; 
+0

非常感謝! – Etienne 2009-10-07 11:10:45

0

可能是試一下像:

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

您是否嘗試使用SQL Profiler進行跟蹤?

相關問題