“导入”按钮中代码如下:
'输入截至日期
Dim Val As Date = Date.Today
If InputValue(Val, "筛选","请输入导入数据的截至日期:") Then
Output.Show(Val)
End If
'删除与并入数据同年的记录
Dim y As Integer = Val.year
Dim dt1 As New Date(y, 1, 1)
Dim dt2 As Date = dt1.AddYears(1)
Dim Filter1 As String = "截至日期 >= #" & dt1 & "# And 截至日期 < #" & dt2 & "#"
DataTables("储蓄积分").DeleteFor(Filter1)
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "excel文件|*.xls;*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim mg As New Merger
mg.SourcePath = dlg.FileName
Dim book As new XLS.Book(dlg.FileName)
mg.SourceTableName = book.Sheets(0).Name & "$"
mg.DataTableName = "储蓄积分"
mg.Format = "Excel"
mg.Merge()
End If
For Each dr As DataRow In DataTables("储蓄积分").DataRows
dr("截至日期") = VAL
Next
出现“未将对象引用设置到对象的实例。”但有1条记录导入系统。这是什么原因?如何解决?
[此贴子已经被作者于2016/4/2 16:43:20编辑过]