Article ID: 141510
Article Last Modified on 10/11/2006
NOTE: If you do not see Xlodbc.xla, click Browse to search for the file. The file is located in the MSQuery folder. In Microsoft Excel versions 5.0 and 7.0, the folder is a subfolder of the Microsoft Excel folder. In Microsoft Excel 97, the folder is a subfolder of the Library folder located under the Office folder. Select the Xlodbc.xla file, and then click OK.
' Dimension the variable.
Dim Chan as Integer
' Establish a connection to the data source specifying the user ID and
' password.
chan = SQLOpen("dsn=my datasource;uid=myuid;pwd=password")
' Execute a SQL statement.
SQLExecquery chan, "select * from customer"
' Retrieve the query results and place them on the worksheet.
SQLRetrieve chan, Range("sheet2!a1")
' Close the connection.
SQLClose chan
End Sub
SQLOpen
SQLOpen
Additional query words: sql id XL
Keywords: kbdtacode kbhowto kbprogramming KB141510