我試圖從CodeBehind中的DetailsView中的標籤引用文本,然後通過存儲過程傳遞它。VB.NET在DetailsView中引用標籤的文本
我的DetailsView是DetailsView1,兩個字段是lblDialID & lblCallbackID。我已將它們轉換爲TemplateFields。數據填充正確,但是當我試圖抓取數據並通過它時,我沒有收到任何結果。
存儲過程不執行它的行動,並在變量的Response.Write不會產生任何結果,因此assumedly我只是抓住空氣稀薄:)
任何指導意見嗎?
Protected Sub lnkCBtoPUB_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim Conn As New SqlConnection("Data Source=SERVER;Initial Catalog=DATABASE;User ID=USER;Password=PASSWORD")
Dim MyCommand As New SqlCommand
Dim sDialID As Label = CType(DetailsView1.FindControl("lblDialID"), Label)
Dim sCallbackID As Label = CType(DetailsView1.FindControl("lblCallbackID"), Label)
Conn.Open()
MyCommand.Connection = Conn
MyCommand.CommandType = CommandType.StoredProcedure
MyCommand.CommandText = "spAlterAgentCallback"
MyCommand.Parameters.AddWithValue("@DialID", sDialID.Text)
MyCommand.Parameters.AddWithValue("@CallbackID", sCallbackID.Text)
MyCommand.ExecuteNonQuery()
Conn.Close()
Conn.Dispose()
MyCommand.Dispose()
End Sub
這裏是存儲過程
ALTER PROCEDURE [dbo].[spAlterAgentCallback]
@DialID AS INT,
@CallBackID AS INT
AS
BEGIN
UPDATE DIAL
SET CBDATETIME = GETDATE(),
AgentID = '',
CRC = 'SCBR',
Notes = 'This Record Was Recently a Callback for Another Agent.'
WHERE DialID = @DialID
DELETE FROM CALLBACK WHERE CallBackID = @CallBackID
END
<> 難道這也是因爲我傳遞一個字符串,但SP正在它作爲一個INT?這應該不會造成問題,但?
謝謝!
我做了適當的修改,而且我無法產生想要的結果。 – RogueSpear00
存儲過程非常簡單。我已經添加了上面的存儲過程。 – RogueSpear00
SP在SQL中工作正常,在編寫VB之前已經過測試。我仍然假設我沒有正確地抓住價值觀,並不是你錯了,但那只是我的假設。 – RogueSpear00