PC Review


Reply
Thread Tools Rate Thread

Creating ODBC link within SELECT statement

 
 
Preacher Man
Guest
Posts: n/a
 
      31st Jan 2006
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.


 
Reply With Quote
 
 
 
 
Ed Ferrero
Guest
Posts: n/a
 
      31st Jan 2006
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.
>



 
Reply With Quote
 
=?Utf-8?B?Um9uIENvZGVycmU=?=
Guest
Posts: n/a
 
      31st Jan 2006
Check this website. I use the DSN-less connections presented there and
they've worked fine on other PCs:

http://www.carlprothman.net/Default.aspx?tabid=81

Does that help?

***********
Regards,
Ron

XL2002, WinXP-Pro


"Preacher Man" wrote:

> 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.
>
>
>

 
Reply With Quote
 
Jim
Guest
Posts: n/a
 
      31st Jan 2006
Preacher,
Did you create your ODBC link using excel menus Data \ Get External
Data \ New Database Quey
?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating new link to external data (ODBC) Kristibaer Microsoft Excel Misc 2 13th May 2009 07:21 PM
Creating ODBC link within SELECT statement Preacher Man Microsoft Excel Discussion 1 31st Jan 2006 07:54 PM
Creating ODBC link within SELECT statement Preacher Man Microsoft Excel Worksheet Functions 2 31st Jan 2006 07:54 PM
Creating ODBC link over Terminal Server Daryl Microsoft Windows 2000 Terminal Server Clients 4 17th Dec 2003 11:41 PM
SELECT INVALID SELECT STATEMENT TO FORCE ODBC DRIVER TO UNPREPARED STATE Jason Teng Microsoft Windows 2000 2 28th Oct 2003 07:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:10 AM.