Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is my macro:
Sub SQL2ARRAY() connstring = "ODBC;DSN=DBSRV;UID=;PWD=;Database=BPC_Reports " sqlstring = "SELECT * FROM BPC_Reports.dbo.Officers" Set RS = CreateObject("ADODB.Recordset") RS.Open "sqlstring", "connstring" YourVar = RS.GetRows Set RS = Nothing MsgBox YourVar End Sub But I'm getting this error: Run-time error '-2147467259 (80004005)': Automation error Unspecified error I'm completely new to SQL queries and using them in excel macros... What am I missing? AA2e72E wrote: I need my code for the SQL query to put the results into an array varable (or something like that) that I can refrence. Try: Set RS = CreateObject("ADODB.Recordset") RS.Open "Your SQL", "Your Connection String" YourVar= RS.GetRows Set RS = Nothing At this point, YourVar is an array (2-dimensional). |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to create a lookup table with an added varable? | Excel Worksheet Functions | |||
Error: Number of query values and destination fields are not the s | Excel Worksheet Functions | |||
How can I assign a varable to equal an array? (it allready has a name) | Excel Programming | |||
Query for data in an array | Excel Programming | |||
Range as varable | Excel Programming |