传递值时读取存储过程对我不起作用 [英] Reading a Stored Proc not working for me when passing values
本文介绍了传递值时读取存储过程对我不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这对我不起作用?我下面的代码有什么问题?我正在尝试读取存储的过程并将值应用于标签.收到错误提示CareerInner 附近的语法不正确"........
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
我的存储过程
My Stored Proc
ALTER PROCEDURE [dbo].[CareersInner]
@ID varchar(10)
AS
BEGIN
SET NOCOUNT ON;
SELECT * FROM Careers WHERE ID = @ID
END
推荐答案
Comm.CommandType = CommandType.StoredProcedure;
这篇关于传递值时读取存储过程对我不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文