Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Bret wrote: I need sample of VBA code of the best way to: 1) do a SQL connection from Excel 2) Execute a query statement that returns the result to a cell. Sub test() Dim rs As Object Set rs = CreateObject("ADODB.Recordset") rs.Open _ "SELECT CompanyName FROM Customers", _ "Provider=SQLOLEDB.1;Data Source=(local);" & _ "Initial Catalog=Northwind;" & _ "User Id=sa;Password=;" Sheet1.Range("A1").CopyFromRecordset rs End Sub Jamie. -- |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert hard coded query criteria to Parameter Query | Excel Discussion (Misc queries) | |||
Excel 2007 / MS Query - editing existing query to another sheet | Excel Discussion (Misc queries) | |||
Save data retreived from query without saving query | Excel Discussion (Misc queries) | |||
Stop to modify the SQL query manually entered into query ! | Excel Programming | |||
Problem with .Background Query option of ODBC Query | Excel Programming |