参数化查询'(@ username nvarchar(4000))UPDATE卖家设置状态='已停用'需要参数' @ username',这是未提供的

时间:2014-11-07 17:24:20

标签: vb.net sql-server-express

您好我的代码有问题,我无法弄清楚问题..如果有人可以帮助..谢谢你

Protected Sub btnActive_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnActive.Click

Dim connectionString As String = "Data Source = .\SQLEXPRESS; AttachDbFileName=|DataDirectory|Petite.mdf; Integrated Security=True; User Instance=True"

Dim conn As SqlConnection = New SqlConnection(connectionString)

Dim cmd As SqlCommand

Dim myupdate As String

    myupdate = " UPDATE Seller Set Status='active' WHERE Username=@Username"

        cmd = New SqlCommand(myupdate, conn)
    cmd.Parameters.AddWithValue("@Username", Session("Username"))

        conn.Open()
        cmd.ExecuteNonQuery()

    MsgBox("Account has been successfully activated!!")

    Response.Redirect("AdminSellers.aspx")
        conn.Close()
End Sub

我收到此错误

  

参数化查询'(@ username nvarchar(4000))UPDATE Seller Set Status ='deactivated'需要参数'@username',这是未提供的。

0 个答案:

没有答案