Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default External query of SQL server

Never mind, I found it. There was a couple typos in my SQL Select
statement.

Thanks,
Linn

"Linn Kubler" wrote in message
...
Hi,

I want to use Excel 2003 to query data from a SQL 2000 server. If I
create
the ODBC connection with the query wizzard it works fine. But I would
like
to avoid having to install that on everyone's computers so I'm writing an
application to run this report. I'm thinking I can then save it with a
workbook and pass it around that way.

At any rate, I'm having a problem retrieving the data now. I setup my
macro
like this:

Dim lsSortBy, strMessge As String
Dim oQt As QueryTable

' Setup the connection string
DefineConnection

' Setup the SQL select command
DefineSQL

' Create the destination workbook
Set NewBook = Workbooks.Add

' Setup the report destination worksheet
With NewBook.Worksheets("sheet1")
.Range("A1").Value = "Inventory Valuation Report"
.Range("A2").Value = Now()
' Run the query
Set oQt = .QueryTables.Add( _
Connection:=strConn, _
Destination:=.Range("A4"), _
Sql:=strSQL)

oQt.Refresh

End With

What I get is cell A4 says, "ExternalData_1". Any ideas what's going on?
I
don't get any error messages so I think everything is working. I'm
prompted
for the username and password for accessing the SQL server and if I type
the
wrong one in I do get an error, so I'm thinking that part is working. How
should I trouble shoot this?

Thanks in advance,
Linn





Reply
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
Change Server for Query Cinco Excel Discussion (Misc queries) 3 July 31st 09 01:04 AM
Query SQL Server from Excel Doctorjones_md Excel Discussion (Misc queries) 1 January 6th 07 08:35 AM
Query SQL Server from Excel Doctorjones_md Excel Worksheet Functions 1 January 6th 07 08:35 AM
Excel Query linking to External (outside domain) SQL server Jeanne Conde Excel Programming 0 July 21st 05 08:00 PM
Query SQL Server Kevin L Excel Programming 1 November 30th 04 09:11 PM


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

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

About Us

"It's about Microsoft Excel"