Solved

TQuery Passed as parameter? OK?

Posted on 1997-03-13
2
222 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now