在调整自动填充列的大小时,无法执行此操作

时间:2015-12-17 12:30:12

标签: vb.net datagridview

     Try
        MysqlConn.Open()
        For i As Integer = Me.DataGridView1.SelectedRows.Count - 1 To 0 Step -1           
            Dim Query2 As String 
            Query2 = "Update blist SET quantity=(quantity-1) where quantity = '" & Me.DataGridView1.SelectedRows(i).Cells(0).Value.ToString & "' "
            COMMAND = New MySqlCommand(Query2, MysqlConn)
            SDA.SelectCommand = COMMAND
            SDA.Fill(dbDataSet)
            bSource.DataSource = dbDataSet
     **error**Me.DataGridView1.DataSource = bSource**error**
            SDA.Update(dbDataSet)
            TextBox2.Text = ""
            MessageBox.Show("Success", "Informed", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Next
        MysqlConn.Close()
    Catch ex As MySqlException
        MessageBox.Show(ex.Message)
    Finally
        MysqlConn.Dispose()
    End Try
End Sub

我无法在互联网上找到相关问题我该怎么办?我试图在用户借用它时在SqlDB上扣除1个数量。是!它执行sql命令,但我有这种类型的错误。

bsource =绑定源 SDA = MysqlAdapter

1 个答案:

答案 0 :(得分:0)

您可以尝试插入

DatarGidView1.SuspendLayout

在发生错误的行之前,

DataGridView1.ResumeLayout
之后,虽然我不确定这是否有效