Solved

TQuery Passed as parameter? OK?

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

772 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