BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Timeout Expired using Excel and QueryTable automation

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Darren Guy
Guest





PostPosted: Wed Apr 27, 2005 4:32 pm    Post subject: Timeout Expired using Excel and QueryTable automation Reply with quote



I am using Delphi 7, and Excel 2003, with MS SQL 2000 on Win XP pro + sp2

I have some code that calls Excel's QueryTable to call several stored
procedures. However, I am getting a timeout expired error after 30 seconds.
There are several sp's that can run for several minutes.


This is my code, what can i do to get rid of these timeout errors.

procedure TPreRules.PopulateSpreadsheet(const recGetParamName: string);
const
sspi = 'ODBC;DSN=%s;Trusted_Connection=Yes;';
up = 'ODBC;DSN=%s;UID=%s;PWD=%s;';
var ExcelQuery: Variant;
sql, connection: Variant;
destination: variant;
ss: string;
begin
if ( fSSPI ) then
connection := Format(sspi, [fODBC])
else
connection := Format(up, [fODBC, fUserName, fPassword]);
sql := 'EXEC ' + recGetParamName;
Destination := fWorkSheet.Range['A2'];
ExcelQuery := fWorkSheet.QueryTables.Add(connection,destination, sql);
ExcelQuery.Name := 'Query from ' + fODBC;
ExcelQuery.FieldNames := true;
ExcelQuery.RowNumbers := false;
ExcelQuery.FillAdjacentFormulas := False;
ExcelQuery.PreserveFormatting := True;
ExcelQuery.RefreshOnFileOpen := False;
ExcelQuery.BackgroundQuery := false;
ExcelQuery.RefreshStyle := $00000001;
ExcelQuery.SavePassword := False;
ExcelQuery.SaveData := True;
ExcelQuery.AdjustColumnWidth := True;
ExcelQuery.RefreshPeriod := 0;
ExcelQuery.PreserveColumnInfo := True;
//ExcelQuery.RefreshBackgroundQuery :=False; // not recognized by
automation object
ExcelQuery.Refresh;
end;

I created a macro in excel to run the stored proc that I am having problems
with in my delphi app, and it will execute with no timeout in Excel. IT was
the excel macro code that i used in my Delphi Code.

thanks in advance




Darren


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.