我已在表格中将这些声明为私有。
Private callLogConnection As New OleDbConnection()
Private schDataAdapter = New OleDbDataAdapter("Select * From tbl_schtime", _ callLogConnection)
Private schCommmandBuilder = New OleDbCommandBuilder(schDataAdapter)
Private schDataTable As New DataTable
Private schRowPosition As Integer = 0
Private qryexceptionDataAdapter = New OleDbDataAdapter("Select * From _ qry_exceptionUpdate", callLogConnection)
Private exceptionBindingSource = New BindingSource()
Private exception2BindingSource As New BindingSource
Private exceptionCommandBuilder As OleDbCommandBuilder = New _ OleDbCommandBuilder(qryexceptionDataAdapter)
Private qryexceptionDataTable As New DataTable
Private qryexceptionRowPostiion As Integer = 0
Private tbl_ExceptionDataSet As DataSet = New DataSet
Private exceptionDataTable As New DataTable
我已经在表单加载中声明了这些对象
qryexceptionDataAdapter.Fill(qryexceptionDataTable)
'linking the qryexception table to binding source
exceptionBindingSource.DataSource = qryexceptionDataTable
'showing the binding source in the datagrid view
dgvExceptions.DataSource = exceptionBindingSource
这是我的保存按钮命令,用于从 datagridview 更新我的表。
Private Sub btnSaveException_Click(sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveException.Click
Try
Me.Validate()
Me.qryexceptionDataAdapter.Update(Me.tbl_ExceptionDataSet.Tables("qry_exceptionUpdates"))
Me.tbl_ExceptionDataSet.AcceptChanges()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub code here
但我不断得到:
System.Reflection.AmbiguousMatchException: Overload resolution failed because no Public 'Update' is most specific for these arguments:
'Public Function Update(dataTable As System.Data.DataTable) As Integer':
Not most specific.
'Public Overrides Function Update(dataSet As System.Data.DataSet) As Integer':
Not most specific.
'Public Function Update(dataRows As System.Data.DataRow()) As Integer':
Not most specific.
at Microsoft.VisualBasic.CompilerServices.OverloadResolution.ResolveOverloadedCall(String MethodName, List`1 Candidates, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, BindingFlags LookupFlags, Boolean ReportErrors, ResolutionFailure& Failure)
at Microsoft.VisualBasic.CompilerServices.OverloadResolution.ResolveOverloadedCall(String MethodName, MemberInfo[] Members, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, BindingFlags LookupFlags, Boolean ReportErrors, ResolutionFailure& Failure)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ResolveCall(Container BaseReference, String MethodName, MemberInfo[] Members, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, BindingFlags LookupFlags, Boolean ReportErrors, ResolutionFailure& Failure)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at Call_Log.CallLogForm.btnSaveException_Click(Object sender, EventArgs e) in C:\Users\mdutton\Desktop\Call Log\Call Log\CallLogForm.vb:line 174