如何将多个相同结构的excel导入到SqlServer
本人是vb新手’以下是我写的部分代码(实现了将一个Excel文件导入到SqlServer的功能),现在要导入多个Excel文件。请大侠们指教,谢谢!
'---------------------------------------------------------------------------------------------------
'选择excel文件的按钮
Private Sub cmdSelExcel_Click(Index As Integer)
txtSelExcel(Index) = SetFileDialog
End Sub
Private Function SetFileDialog() As String
Dim strFilePath As String
With CDFile
.FileName = ""
.Filter = "Excel(*.xls)|*.xls|All Files|*.*"
.Action = 1
strFilePath = CDFile.FileName
End With
If strFilePath <> "" Then SetFileDialog = strFilePath
End Function
'-------------------------------------------------------------------------
下面就是连接数据库,读取excel中的数据,insert into sql数据库中。
请各位大侠帮忙。可以是选择一个文件夹,将其中的xls文件中的数据全部导入,另外也可以支持多选,将选中的excel文件中的数据导入。谢谢!