Board index » delphi » Delphi 4 - SQL 7. SetRange doesn't work

Delphi 4 - SQL 7. SetRange doesn't work

     HI!!!, what are the rules I should follow so I can use the SetRange
with a Table from a SQL Server 7, I always have problems to define a
Range in a Table, please help me!

    Thanks!

    Miguel Mesa

 

Re:Delphi 4 - SQL 7. SetRange doesn't work


Miguel,

   Save yourself a lot of time and effort and use TQuerys (never, ever use
TTables).  For example

Select * from Invoices Where InvoiceDate >= '10-01-1999 12:00AM' AND
InvoiceDateTime <= '10-31-1999 11:59PM'
or
Select * from Invoices Where InvoiceDate BETWEEN '10-01-1999 12:00AM' AND
'10-31-1999 11:59PM'

Good luck
krf

Ing. Miguel Agustin Mesa Perez wrote in message <387B7A06.F2579...@up.mx>...

Quote

>     HI!!!, what are the rules I should follow so I can use the SetRange
>with a Table from a SQL Server 7, I always have problems to define a
>Range in a Table, please help me!

>    Thanks!

>    Miguel Mesa

Re:Delphi 4 - SQL 7. SetRange doesn't work


Hi Kevin!!!!, thanks for you support, but, I have a problem with the querys,
thats why I stop using them. How can I position in an specific record on the
Query???, I have problems with the function Locate of the TQuery, I don't
understand a problem with variant types, my code produce an "invariant type
conversion", my code looks like this:

function TShell.SearchQueryRecord(dbQuery : TQuery; aCol : Array of String;
const aSearchData : Array of String) : Boolean;
var
  i : Integer;
  aSearchFor : String;
  vVariant : Variant;
begin
  vVariant := VarArrayCreate([low(aSearchData),high(aSearchData)], varVariant);

  aSearchFor := '';
  for i:=low(aSearchData) to high(aSearchData) do
  begin
    aSearchFor := aSearchFor + aCol[i]+ ';';
    vVariant[i] := aSearchData[i];
  end;
  if dbQuery.Locate(aSearchFor, vVariant, [loPartialKey]) then
    Result := True
  else
    Result := False;
end;

Quote
Kevin Frevert wrote:
> Miguel,

>    Save yourself a lot of time and effort and use TQuerys (never, ever use
> TTables).  For example

> Select * from Invoices Where InvoiceDate >= '10-01-1999 12:00AM' AND
> InvoiceDateTime <= '10-31-1999 11:59PM'
> or
> Select * from Invoices Where InvoiceDate BETWEEN '10-01-1999 12:00AM' AND
> '10-31-1999 11:59PM'

> Good luck
> krf

> Ing. Miguel Agustin Mesa Perez wrote in message <387B7A06.F2579...@up.mx>...

> >     HI!!!, what are the rules I should follow so I can use the SetRange
> >with a Table from a SQL Server 7, I always have problems to define a
> >Range in a Table, please help me!

> >    Thanks!

> >    Miguel Mesa

Re:Delphi 4 - SQL 7. SetRange doesn't work


Maybe you could use the query as table in the way to control the records, I mean,
you can control the query as follows:

     while not query.eof do
      begin
            if query.fieldvalues['field'] = fieldvalue then
              -----
           query.next;    // this line is super escenttial for this loop works
       end

Ing. Miguel Agustin Mesa Perez escribi:

Quote
> Hi Kevin!!!!, thanks for you support, but, I have a problem with the querys,
> thats why I stop using them. How can I position in an specific record on the
> Query???, I have problems with the function Locate of the TQuery, I don't
> understand a problem with variant types, my code produce an "invariant type
> conversion", my code looks like this:

> function TShell.SearchQueryRecord(dbQuery : TQuery; aCol : Array of String;
> const aSearchData : Array of String) : Boolean;
> var
>   i : Integer;
>   aSearchFor : String;
>   vVariant : Variant;
> begin
>   vVariant := VarArrayCreate([low(aSearchData),high(aSearchData)], varVariant);

>   aSearchFor := '';
>   for i:=low(aSearchData) to high(aSearchData) do
>   begin
>     aSearchFor := aSearchFor + aCol[i]+ ';';
>     vVariant[i] := aSearchData[i];
>   end;
>   if dbQuery.Locate(aSearchFor, vVariant, [loPartialKey]) then
>     Result := True
>   else
>     Result := False;
> end;

> Kevin Frevert wrote:

> > Miguel,

> >    Save yourself a lot of time and effort and use TQuerys (never, ever use
> > TTables).  For example

> > Select * from Invoices Where InvoiceDate >= '10-01-1999 12:00AM' AND
> > InvoiceDateTime <= '10-31-1999 11:59PM'
> > or
> > Select * from Invoices Where InvoiceDate BETWEEN '10-01-1999 12:00AM' AND
> > '10-31-1999 11:59PM'

> > Good luck
> > krf

> > Ing. Miguel Agustin Mesa Perez wrote in message <387B7A06.F2579...@up.mx>...

> > >     HI!!!, what are the rules I should follow so I can use the SetRange
> > >with a Table from a SQL Server 7, I always have problems to define a
> > >Range in a Table, please help me!

> > >    Thanks!

> > >    Miguel Mesa

--

JC
e-mail : jcsa...@buzon.uach.mx
ICQ # : 13614513

Re:Delphi 4 - SQL 7. SetRange doesn't work


The SetRange are easy to use

SetRange([value1,value2,...],[valueX,ValueY,...])
where value1,and value2,... are the begin of the range and valueX, and
valueY,... are the end of it and previously you define the table indexed of
all the fields into the subrange; so if you have (value1 and valueX) values
of Field1 and (value2 and valueY) values of Field2 the Table would had
indexed of Field1,Field2.

Ing. Miguel Agustin Mesa Perez escribi en mensaje
<387B7A06.F2579...@up.mx>...

Quote

>     HI!!!, what are the rules I should follow so I can use the SetRange
>with a Table from a SQL Server 7, I always have problems to define a
>Range in a Table, please help me!

>    Thanks!

>    Miguel Mesa

Other Threads