Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
SQL Server 2000. Excel 2003. I know how to set an Excel sheet to query my
SQL Server database table(s) and populate the sheet cells. This works for some of my needs. But in general I would like to be able to do a query and have the results go to a record set, that I can then programmatically manipulate. Can anyone help me with some sample VBA code that populates a record set from a SQL Server database? Thanks and God bless for any help provided. What I am using now to populate the Excel sheet is: With ThisWorkbook.Sheets("Project Definitions").QueryTables.Add(Connection:= _ "ODBC;DSN=AFNINI_1;Description=Good_News_FE;UID=FE open7;;APP=Microsoft Office 2003;WSID=DOUG;DATABASE=Good_News_FE" _ , Destination:=Range("J1")) .CommandText = "SELECT GL7PROJECTS.PROJECTID, GL7PROJECTS.DESCRIPTION, GL7PROJECTS.STARTDATE, TABLEENTRIES.DESCRIPTION FROM (GL7PROJECTS LEFT JOIN GL7PROJECTATTRIBUTES ON GL7PROJECTS.GL7PROJECTSID = GL7PROJECTATTRIBUTES.PARENTID) LEFT JOIN TABLEENTRIES ON GL7PROJECTATTRIBUTES.TABLEENTRIESID = TABLEENTRIES.TABLEENTRIESID ORDER BY GL7PROJECTS.PROJECTID;" .Name = "Project Attributes Query" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlOverwriteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh BackgroundQuery:=False End With -- Dr. Doug Pruiett Good News Jail & Prison Ministry www.goodnewsjail.org |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Querying Large Database | Excel Discussion (Misc queries) | |||
Querying SQL Server from Excel | Excel Discussion (Misc queries) | |||
Database access & querying | Excel Programming | |||
Querying Access Database | Excel Worksheet Functions | |||
Querying a database for values in each row | Excel Programming |