A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Creating ODBC link within SELECT statement



 
 
Thread Tools Display Modes
  #1  
Old January 31st, 2006, 08:48 AM posted to microsoft.public.excel.charting
external usenet poster
 
Posts: n/a
Default Creating ODBC link within SELECT statement

Hi Preacher Man,

Please don't cross-post to multiple newsgroups.

This bit of code sets a connection to Northwind on my local server

Sub UpdatePivot()
Dim pvt As PivotTable
Dim pCache As PivotCache
Dim sSQL, sServer, sUser As String

Set pvt = PivotTables(1)
Set pCache = pvt.PivotCache

' write a SQL query
sSQL = "SELECT Orders.* FROM master.dbo.Orders Orders"

' select the server and login
sServer = "EDSLAP"
sUser = "sa" ' log in as sa, will ask for pwd

pCache.CommandText = sSQL

pCache.Connection = "ODBC; DRIVER=SQL SERVER;" _
& "SERVER=" & sServer & ";" _
& "UID=" & sUser & ";" _
& "APP=Microsoft Office 2003"

pCache.Refresh

End Sub

Ed Ferrero
Microsoft Excel MVP
http://www.edferrero.com

Is this possible. To explain myself, here is my situation. I created an
Excel Spreadsheet that uses an ODBC link to a SQL database. In order for
anyone to use this file on their PC, that same ODBC link must be setup.
Is
their some code I can use within a Select Statement that will allow me to
bypass having to create an ODBC on everyone's PC?

Thanks.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visio Shortcuts [email protected] Visio 1 December 29th, 2006 12:28 AM
NEED HELP! User-level security/SQL question Matt Mcd General Discussion 0 October 21st, 2005 07:27 PM
Query with sub SELECT statement not allowing sum of a field Pouty Running & Setting Up Queries 1 June 22nd, 2005 01:02 PM
Conversion SVC Worksheet Functions 9 February 28th, 2005 03:29 PM
Specifying field's data type in select statement Benjamin Pratt Running & Setting Up Queries 2 January 7th, 2005 10:26 PM


All times are GMT +1. The time now is 10:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.