Solved

TQuery Passed as parameter? OK?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to use Hashing sha1 in Delphi 2010 4 206
Delphi cmd execution 6 56
code issue 8 100
RESTRequest Parameter 4 15
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

24 Experts available now in Live!

Get 1:1 Help Now