Solved

TQuery Passed as parameter? OK?

Posted on 1997-03-13
2
242 Views
Last Modified: 2010-04-04
Using Delphi 1.0 and DBase tables...
I am trying to pass a query 7 times to fill a string grid, and it
returns the same, wrong, data each time.

This is the call I am making.

   with frmWeek do    {Fill in column headers with day of week/date}
      for i := 0 to 6 do
         sgWeek.Cells[ i,0 ] := dayOfWeek[ i ] + ' ' +
         JulianDayToGregorianString( (weekstart + i)) ;

   sgcol := 1; {First Usable Column}
   while not (weekstart > weekend) do begin
      CalendarSetRange(weekstart, qWeek);  {This is the painful call}
      qWeek.First;
      dsi := 1;
      while not ( dsi > qWeek.RecordCount )do begin  {While not EOF}
         for sgi := 0 to qWeek.FieldCount - 1 do begin
            with sgWeek do
                 Cells[sgi,dsi] := 'B  ' + qWeek.fields[0].AsString +
                                                '    E ' + qWeek.fields[1].AsString + '  ' +
                                                qWeek.fields[4].AsString;
         qWeek.next;
         end; {for}
         dsi := dsi + 1;
      end; {while}
      sgcol := sgcol + 1;
      weekstart := weekstart + 1.0;
      Update;
   end; {while}
end;{Dates}

-----------------------------
Separate Unit that the query is passed to:
--------------------

procedure CalendarSetRange( start : Double; dayquery : TQuery) ;
{Run query to display assets used during the 24 hour period }
var
    dateToShow : Double;

begin
   dateToShow := start;
   dayquery.Close;
   dayquery.ParamByname('EndTime').AsFloat := int( dateToShow );
   dayquery.ParamByname('StartTime').AsFloat := int( dateToShow + 1.0
);
   dayquery.Prepare;
   dayquery.Close;
   dayquery.Open;
end;

0
Comment
Question by:lorens
2 Comments
 

Author Comment

by:lorens
ID: 1334859
Edited text of question
0
 
LVL 2

Accepted Solution

by:
javiertb earned 100 total points
ID: 1334860
You must include the DBTABLES in your uses line of your separate unit. I don't know if this is what you mean but otherwise I get no error if I pass a Tquery as parameter.

I hope this helps.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question