任何人都可以帮我解决这个问题。我想做这样的事情。
strSQL = SELECT [filename1].[" & xlSheet.Name & "$].Col1
, [filename1].[" & xlSheet.Name & "$].Col2
FROM [filename1].[" & xlSheet.Name & "$]
UNION ALL
SELECT [filename2].[" & xlSheet2.Name & "$].Col1
, [filename2].[" & xlSheet2.Name & "$].Col2
FROM [Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename2+ ";Extended Properties=Excel 12.0;HDR=Yes].[" & xlSheet2.Name & "$]
WHERE [filename1].[" & xlSheet.Name & "$].Col1= [filename2].[" & xlSheet2.Name & "$].Col1
Using conExcel As New OleDb.OleDbConnection()
conExcel.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename1 + ";Extended Properties=Excel 12.0;HDR=Yes"
conExcel.Open()
cmdSelect.CommandText = strSQL
cmdSelect.Connection = conExcel
intRowsCount = cmdSelect.ExecuteNonQuery()