问题描述
这是我的代码,我错过了一些东西,因为。它按钮点击事件没有更新表,也没有给我一个错误。
Here is my code, I am missing something because. It button click event is not updating the table and not giving me an error.
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim ShoppingCart_ID As String
ShoppingCart_ID = "123ABC"
Dim Confirmation As SqlDataSource = New SqlDataSource
Confirmation.ConnectionString = ConfigurationManager.ConnectionStrings("GARNETConnectionString").ToString()
Dim AdvertisementID As Integer
AdvertisementID = DirectCast(FormView1.FindControl("AdvertisementIDLabel"), Label).Text
Confirmation.UpdateCommand = "UPDATE [Advertisement_TB] SET ([ShoppingCart_ID] = @ShoppingCart_ID) WHERE ([AdvertisementID] = @AdvertisementID)"
Confirmation.UpdateParameters.Add("AdvertisementID", AdvertisementID)
Confirmation.UpdateParameters.Add("ShoppingCart_ID", ShoppingCart_ID)
'***
'Label1.Text = ShoppingCart_ID - Tested that the data is passing but no update to the ShoppingCart_ID
'Label2.Text = AdvertisementID - Tested that the data is passing
End Sub
我的尝试:
受保护的子按钮2_Click(发件人)作为Object,e As EventArgs)处理Button2.Click
Dim ShoppingCart_ID As String
ShoppingCart_ID =123ABC
$ /
Dim Confirmation As SqlDataSource = New SqlDataSource
Confirmation.ConnectionString = ConfigurationManager.ConnectionStrings( GARNETConnectionString)。ToString()
昏暗的广告ID为整数
AdvertisementID = DirectCast(FormView1.FindControl(AdvertisementIDLabel),Label).Text
Confirmation.UpdateCommand =UPDATE [Advertisement_TB] SET(ShoppingCart_ID)VALUES(@ShoppingCart_ID)其中[AdvertisementID] = @AdvertisementID
Confirmation.UpdateParameters.Add( AdvertisementID,AdvertisementID)
Confirmation.UpdateParameters.Add(ShoppingCart_ID,ShoppingCart_ID)
'***
'Label1.Text = ShoppingCart_ID - 测试数据正在传递但没有更新到ShoppingCart_ID
'Label2.Text = AdvertisementID - 测试数据正在通过
End Sub
What I have tried:
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim ShoppingCart_ID As String
ShoppingCart_ID = "123ABC"
Dim Confirmation As SqlDataSource = New SqlDataSource
Confirmation.ConnectionString = ConfigurationManager.ConnectionStrings("GARNETConnectionString").ToString()
Dim AdvertisementID As Integer
AdvertisementID = DirectCast(FormView1.FindControl("AdvertisementIDLabel"), Label).Text
Confirmation.UpdateCommand = "UPDATE [Advertisement_TB] SET (ShoppingCart_ID) VALUES (@ShoppingCart_ID) Where [AdvertisementID] = @AdvertisementID"
Confirmation.UpdateParameters.Add("AdvertisementID", AdvertisementID)
Confirmation.UpdateParameters.Add("ShoppingCart_ID", ShoppingCart_ID)
'***
'Label1.Text = ShoppingCart_ID - Tested that the data is passing but no update to the ShoppingCart_ID
'Label2.Text = AdvertisementID - Tested that the data is passing
End Sub
推荐答案
Confirmation.UpdateParameters.Add("AdvertisementID", AdvertisementID)
Confirmation.UpdateParameters.Add("ShoppingCart_ID", ShoppingCart_ID)
Confirmation.Update();
这篇关于如何使用sqldatasource&更新SQL表confirmation.connectionstring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!