将几个EXCEL表的数据用SQL读取后导入到DATAGRIDVIEW
有3张或多张EXCEL表
如A 表 B 表 C表
格式完全一致
通过代码取得A表的数据并导入到DATAGRIDVIEW
Dim strPath As String = "d:\A.xls"
Dim search_command As String
Dim name As String = "结算表"
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";Extended Properties ='Excel 8.0;HDR=False;IMEX=1'"
Using OleConn As New OleDb.OleDbConnection(strConn)
OleConn.Open()
search_command = "SELECT * FROM [" & name & "$] "
Dim OleDaExcel As New OleDb.OleDbDataAdapter(search_command, OleConn)
Dim ds As New DataSet()
OleDaExcel.Fill(ds)
DATAGRIDVIEW1.DataSource = ds.Tables(0)
OleConn.Close()
End Using
请问如何将B表或C表也添加到DATAGRIDVIEW1中,如果按以上代码进行循环最后只有C表存在,A表B表数据都没了