Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
lc lc is offline
external usenet poster
 
Posts: 13
Default PivotTable and connection string


Sorry about the report (really not my habit) but my original post since
yesterday went all the way down....


With Excel 2003, I'm trying to replace connection string and make query
dynamic but am getting "strange" errors. This is what I have:

Private Sub refreshData(dFrom As Date, dTo As Date)
Dim pt As PivotTable
Dim pc As PivotCache

Set pt = Sheet1.PivotTables(1)
Set pc = ActiveWorkbook.PivotCaches(pt.CacheIndex)

pc.Connection = "SQLOLEDB.1;User ID=sa;Initial Catalog=QuantumPlan;Data
Source=myServer"
pc.CommandText = "select .... '"

pt.PivotCache.Refresh
End Sub

I'm getting 1004 error on pc.Connection line. Anyone has any idea why and
how to get around it?

Thanks a lot.

lc



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default PivotTable and connection string

It is highly probable that your connection string is flawed.

--
Regards,
Tom Ogilvy

"lc" wrote in message
...

Sorry about the report (really not my habit) but my original post since
yesterday went all the way down....


With Excel 2003, I'm trying to replace connection string and make query
dynamic but am getting "strange" errors. This is what I have:

Private Sub refreshData(dFrom As Date, dTo As Date)
Dim pt As PivotTable
Dim pc As PivotCache

Set pt = Sheet1.PivotTables(1)
Set pc = ActiveWorkbook.PivotCaches(pt.CacheIndex)

pc.Connection = "SQLOLEDB.1;User ID=sa;Initial

Catalog=QuantumPlan;Data
Source=myServer"
pc.CommandText = "select .... '"

pt.PivotCache.Refresh
End Sub

I'm getting 1004 error on pc.Connection line. Anyone has any idea why and
how to get around it?

Thanks a lot.

lc





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
How do I use a connection string? BrandenK Excel Discussion (Misc queries) 0 September 25th 07 07:10 PM
Excel 2007 - The connection for this PivotTable has been deleted Michael Excel Discussion (Misc queries) 1 June 22nd 06 08:54 PM
PivotTable and connection string lc Excel Programming 0 November 5th 03 01:32 AM
Can't get connection string right Frank Isaacs Excel Programming 1 October 2nd 03 05:02 AM
What is the connection string ? Jan Karel Pieterse Excel Programming 0 July 25th 03 11:37 AM


All times are GMT +1. The time now is 02:28 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"