数据网格视图中的自定义编辑按钮

时间:2018-12-27 11:15:38

标签: sql-server datagrid

    Dim conn As New SqlConnection

    conn.ConnectionString = ConfigurationManager.ConnectionStrings("ClinicConn").ConnectionString

    Dim sql As String = "UPDATE Patients_tab SET Waiting=@Waiting WHERE ID=@ID"

    conn.Open()

    Dim btn As SqlCommand = New SqlCommand(sql, conn)
    btn.Parameters.Add("ID", SqlDbType.Int)
    btn.Parameters("@ID").Value = ID
    btn.Parameters.AddWithValue("Waiting", "0")

    btn.ExecuteScalar()

    conn.Close()

    GridView1.DataBind()
    GridView2.DataBind()

尝试在自定义按钮中添加此代码,将“ Waiting” col的值从“ 1”更改为“ 0”,并将行从DG1更改为DG2,我得到了此错误

  

此ParameterParameterCollection不包含带有ParameterName'@ID'的SqlParameter

0 个答案:

没有答案