我正在开发一个控制台应用程序,它将获取特定文件夹中的所有 .sql 文件,使用这些文件来查询数据库,然后将每个结果导出到一个 excel 文件中。我已经把所有东西都放到了数据表中。我正在寻求有关使该数据表表现出色的任何建议或指导。任何帮助,将不胜感激。谢谢你。
Imports System.Data.OleDb
Module SqlExport
Sub Main()
Dim SQLString As String
Dim SQLDirectory As New IO.DirectoryInfo("\\Datastore\scripts\SQL")
Dim SQLQueries As IO.FileInfo() = SQLDirectory.GetFiles("*.sql")
Dim CurrentQuery As IO.FileInfo
Dim dt As New DataTable
For Each CurrentQuery In SQLQueries
SQLString = System.IO.File.ReadAllText(CurrentQuery.FullName)
Using connection As New OleDb.OleDbConnection("provider=advantage ole db provider;data source=\\database\dba;advantage server type=ads_remote_server;trimtrailingspaces=true;")
Dim command As New OleDbCommand(SQLString, connection)
Dim da As New OleDb.OleDbDataAdapter(command)
da.Fill(dt)
End Using
Next
End Sub
End Module