Article ID: 142358
Article Last Modified on 8/17/2005
Sub UsingODBCLOgon()
' Dimension the variables.
Dim chan As Integer
Dim NumRows
Dim NumCols
' Initiate a DDE channel to Msquery.
chan = DDEInitiate("MSQuery", "System")
' Execute the ODBCLogon command.
DDEExecute chan, "[ODBCLogon('DSN=NWind',0)]"
' Execute a SQL statement.
DDEExecute chan, "[Open('Select * From Customer')]"
' Request the number of rows.
NumRows = DDERequest(chan, "NumRows")
' Request the number of columns.
NumCols = DDERequest(chan, "NumCols")
' Return the data to Sheet1.
DDEExecute chan, "[Fetch('Excel','Sheet1','R1C1:R" & NumRows(1) & _
"C" & NumCols(1) & "','All/Headers')]"
' Close the DDE channel.
DDETerminate chan
End Sub
ODBCLogon
Additional query words: 5.00c 8.00 97 login logging odbc XL
Keywords: kbhowto kbprogramming kbdtacode KB142358