你好。 Plz帮帮我,我有这个错误 [英] Hi. Plz help me I have this error

查看:117
本文介绍了你好。 Plz帮帮我,我有这个错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

An SqlParameter with ParameterName '@Id' is not contained by this SqlParameterCollection. 





这是我的错误....



我尝试过:





this is my error ....

What I have tried:

Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim cmmd As New SqlCommand
        For i = 0 To GridView1.Rows.Count - 1
            If CType(GridView1.Rows(i).FindControl("CheckBox1"), CheckBox).Checked Then
                cmmd.Parameters("@Id").Value = CType(GridView1.Rows(i).FindControl("TxtId"), TextBox).Text
                cmmd.Parameters("@Setup_Type").Value = CType(GridView1.Rows(i).FindControl("TxtType"), TextBox).Text
                cmmd.Parameters("@Setup_name").Value = CType(GridView1.Rows(i).FindControl("TxtName"), TextBox).Text
                Exit Sub
            Else
                cmmd.Parameters("@Id").Value = ""
                cmmd.Parameters("@Setup_Type").Value = ""
                cmmd.Parameters("@Setup_name").Value = ""
            End If
        Next
    End Sub

推荐答案

在尝试之前,您需要将参数添加到 cmmd 设置

例如
You need to add the parameters to cmmd before attempting to set the Value
e.g.
cmmd.Parameters.AddWithValue("@Id", CType(GridView1.Rows(i).FindControl("TxtId"), TextBox).Text)


这篇关于你好。 Plz帮帮我,我有这个错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆