Thursday, November 20, 2008

Microsoft Excel Connectivity using ODBC connection

How to connect Microsoft Excel connection using ODBC?
[Example below using VB Code:]
Dim XlFile: XlFile="C:\MyExcel.xls"
Dim AdodbCn
Set AdodbCn = CreateObject("ADODB.Connection")
AdodbCn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)}; DBQ=" & XlFile &"; HDR=Yes; IMEX=1;"
'HDR=Yes;" indicates that the first row contains columnnames, not data
'IMEX=1;" tells the driver to always read "intermixed" data columns as text
AdodbCn.Open