这段代码是将MSSQL数据库的所有数据保存到ACC文件中,运行中出现错误提示:语法错误 在查询表达式 '_Sortkey' 中,但是表可以保存到ACC文件中,如何修改,请各位老师指教,谢谢!!
Dim t As String = format(Date.now(),"yyyyMMddHHmmss")
Vars("_kssj") = Date.Now
'全部表加载
For Each dt As DataTable In DataTables
DataTables( dt.Name ).LoadFilter = ""
DataTables( dt.Name ).Load
DataTables( dt.Name ).Save()
Next
Dim Result As DialogResult
Result = MessageBox.Show("数据表加载完成,是否生成ACC?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.no Then
Return
Else
'生成ACC
For Each dt As DataTable In DataTables
If (DataTables( dt.Name ).basetable.Columns.Contains("_Sortkey")) = True
Dim colNames As String = "[_Identify],[_Locked],[_Sortkey]"
For Each c As DataCol In dt.DataCols
colNames += "," & c.Name
Next
Dim ex As New Exporter
ex.SourceTableName = dt.Name
ex.Fields = colNames
ex.filepath = ProjectPath & "MSSQL数据源"& t &".mdb"
ex.Export()
ElseIf (DataTables( dt.Name ).basetable.Columns.Contains("_Identify")) = True
Dim colNames As String = "[_Identify],[_Locked]"
For Each c As DataCol In dt.DataCols
colNames += "," & c.Name
Next
Dim ex As New Exporter
ex.SourceTableName = dt.Name
ex.Fields = colNames
ex.filepath = ProjectPath & "MSSQL数据源"& t &".mdb"
ex.Export()
Else
Dim ex As New Exporter
ex.SourceTableName = dt.Name
ex.filepath = ProjectPath & "MSSQL数据源"& t &".mdb"
ex.Export()
End If
Next
Vars("_jssj") = Date.Now
MessageBox.Show("数据源已保存在项目所在文件夹内")
End If
此主题相关图片如下:捕获2.jpg