在datagridview中保存或编辑时出现问题

时间:2015-05-25 15:35:47

标签: vb.net datagridview

OledbCommand.Prepare method requires all parameters to have an explicitly set type at system.data.common.dbdatadapter.Updatingrowstatuserror

这是我更新数据或在DataGridView中添加和保存行时收到的错误消息。这是我的代码:

Private Sub btnLoad_Click(sender As System.Object, e As System.EventArgs) Handles btnLoad.Click

    Try
        cnn.Open()
        query = "SELECT EmployeeID, TransactionDate, PreviousBalance, CashOnHand, BankBalance, CheckOnHand, PostDatedCheck, ReturnedCheck, StockOnHand, DamagedStocks, Breakages, GoodStocks, EmptyBottles, Expenses, AccountReceivables, Remittance, TotalAmount FROM SalesmanLedger WHERE EmployeeID = @EmployeeID"
        cmd = New OleDbCommand(query, cnn)
        cmd.Parameters.AddWithValue("@EmployeeID", cbEmployees.SelectedValue)
        da = New OleDbDataAdapter(cmd)
        ds = New DataSet
        da.Fill(ds)
        If ds.Tables.Count > 0 Then
            dgvSalesman.DataSource = ds.Tables(0)
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
    Finally
        cnn.Close()
    End Try

End Sub

Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
    Try
        scb = New OleDbCommandBuilder(da)
        da.Update(ds)
    Catch ex As Exception
        MsgBox(ex.ToString)
    Finally
        cnn.Close()
    End Try

End Sub

我在da.update(ds)中收到错误。我需要你的建议。谢谢。

0 个答案:

没有答案