ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Process data in a sheet within workbook using SQL query? (https://www.excelbanter.com/excel-programming/305357-process-data-sheet-within-workbook-using-sql-query.html)

Stevie_mac

Process data in a sheet within workbook using SQL query?
 
I asked this a while back, never really got it pinned down, thought I'd try again.
I'd like to query a sheet in a workbook - example...

Set rs = SomeFunction("SELECT TOP 5 Sales FROM Sheet1")

While Not rs.EOF
'Do something with rs
rs.MoveNext
Wend

Obviously this is in VBA - thats fine.

If this can be done (even if pivot tables have to be used) please help.

Cheers.

PS:
I could, as an alternative, go straight to SQL Server for data, but there are no DSNs set-up on users PCs (nor will
there be).
Is it possible to do my queries directly to SQL Server without a DSN (i.e. using a connection string)?
example...
sConnectionString = "Data Source=server1;Initial Catalog=myDatabaseName;Integrated Security=SSPI"
Set rs = SomeOtherFunction("SELECT TOP 5 Sales FROM SalesTable", sConnectionString)

While Not rs.EOF
'Do something with rs
rs.MoveNext
Wend





Jamie Collins

Process data in a sheet within workbook using SQL query?
 
"Stevie_mac" wrote ...

Is it possible to do my queries directly to SQL Server without
a DSN (i.e. using a connection string)?


You can use ADO with a DSN-less connection string e.g. using OLE DB
provider:

http://www.able-consulting.com/MDAC/...erForSQLServer

Jamie.

--


All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com