LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MS SQL Connection and Retreival


hey guys,

i found the solution by playing around with some stuff i found on
Microsoft's site:



Code:
--------------------

Public Sub return_data()

' Declare the QueryTable object
Dim qt As QueryTable

' Set up the SQL Statement
sqlstring = "select * from test"

' Set up the connection string, reference an ODBC connection
' There are several ways to do this
' Leave the name and password blank for NT authentication
connstring = _
"ODBC;Driver={SQL Server};Server=(local);UID=;PWD=;Database=test"

' Now implement the connection, run the query, and add
' the results to the spreadsheet starting at row A1
With ActiveSheet.QueryTables.Add(Connection:=connstring , Destination:=Range("A1"), Sql:=sqlstring)
.Refresh
End With
End Sub


--------------------


works a treat!

ed


--
edfollett
------------------------------------------------------------------------
edfollett's Profile: http://www.excelforum.com/member.php...o&userid=36227
View this thread: http://www.excelforum.com/showthread...hreadid=560157

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
always recheck data connection library for latest connection strin FurmanGG Excel Discussion (Misc queries) 0 September 14th 07 04:48 PM
no DDE connection?? askmiller Excel Discussion (Misc queries) 0 August 5th 06 09:19 PM
ADO Connection Alex Excel Programming 12 May 5th 06 07:26 PM
mass data retreival from excel book in different folders Nigel Excel Programming 4 March 23rd 06 01:50 AM
Auto Refreshing: data retreival from webpage Matt Lawson[_4_] Excel Programming 2 December 2nd 04 08:13 PM


All times are GMT +1. The time now is 07:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"