从电子表格中导表,程序一直很正常,但今天突然出现提示“SELECT 子句中包含一个保留字、拼写错误或丢失的参数,或标点符号不正确。” ,且以前的使用正常的也出现此问题,不知啥原因,谢谢老师诊断,代码如下(从电子表格中导表):
If e.Form.Controls("TextBox2").Text= "1234" Then
Dim flg As New SaveExcelFlags
flg.RowNumber = True
flg.CellStyle = True
Tables("入站距离").SaveExcel("D:\data\入站距离备份.Xls","",flg)
Forms("窗口1").OPEN
Dim dlg As New OpenFileDialog
dlg.Filter= "Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb"
If dlg.ShowDialog = DialogResult.Ok Then
Dim book As new XLS.Book(dlg.FileName)
Dim flag As Boolean = False
For Each sheet As XLS.Sheet In book.Sheets
If sheet.name = "sheet1" Then
flag = True
End If
Next
If flag Then
Dim ip As New Importer
ip.SourcePath = dlg.FileName
ip.SourceTableName = "sheet1$"
ip.NewTableName ="距离"
ip.Format = "Excel"
ip.Import()
Else
Forms("窗口1").close
msgbox("不存在sheet1")
Return
MainTable = Tables("表A1")
End If
End If
If DataTables.Contains("入站距离") Then
For Each dc As DataCol In DataTables("入站距离").datacols
If DataTables("距离").datacols.Contains(dc.name) = False Then
Forms("窗口1").close
msgbox("所录入表非所需资料")
If DataTables.Contains("距离") Then
MainTable = Tables("距离")
CurrentTable.DataTable.DataRows.Clear()
Dim Builder As New ADOXBuilder
Builder.Open()
With Builder
.DeleteTable("距离")
End With
Builder.Close()
DataTables.Unload("距离")
End If
MainTable = Tables("表A1")
Return
End If
Next
MainTable = Tables("入站距离")
CurrentTable.DataTable.DataRows.Clear()
'DataTables("表A1").DeleteFor("")
Dim f As New Filler
f.SourceTable = DataTables("距离") '指定数据来源
f.SourceCols = "入口站号,入口站名,距离"
f.DataTable = DataTables("入站距离") '指定数据接收表
f.DataCols = "入口站号,入口站名,距离"
'指定数据接收列
f.Fill() '填充数据
Forms("窗口1").Close()
If DataTables.Contains("距离") Then
MainTable = Tables("距离")
CurrentTable.DataTable.DataRows.Clear()
Dim Builder As New ADOXBuilder
Builder.Open()
With Builder
.DeleteTable("距离")
End With
Builder.Close()
DataTables.Unload("距离")
End If
DataTables("入站距离").Save()
MainTable = Tables("表A1")
msgbox("距离录入已OK! ")
Return
Else
Forms("窗口1").Close()
msgbox("导入表名不正确或电子表格格式有问题")
If DataTables.Contains("距离") Then
MainTable = Tables("距离")
CurrentTable.DataTable.DataRows.Clear()
Dim Builder As New ADOXBuilder
Builder.Open()
With Builder
.DeleteTable("距离")
End With
Builder.Close()
DataTables.Unload("距离")
End If
Return
End If
Else
Forms("窗口1").Close()
msgbox("密码错误")
End If