Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread LoadRows with two Params
Fri, Dec 6 2019 1:32 AMPermanent Link

KimHJ

Comca Systems, Inc

I have a Dataset called CustPhoneTbl with this query. The Phone and Mobile are BigInt.

  Select * from customer
  where Phone={Phone=9999999997} or
  Mobile={Mobile=9999999997}

The preview works fine when either of them are correct.



When I run this it will only find the row if the phone is correct.

procedure TDataM.LoadCustomers(Phone: String);
begin
  CustPhoneTbl.Params.Clear;
  CustPhoneTbl.Params.Add('Phone='+Phone);
  CustPhoneTbl.Params.Add('Mobile='+Phone);
  LoadRows(CustPhoneTbl);
end;

What is missing or is this not possible?

Thanks,
Kim
Fri, Dec 6 2019 3:44 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi Kim,

What happens with following:

procedure TDataM.LoadCustomers(Phone: String);
begin
   CustPhoneTbl.Params.Clear;
   CustPhoneTbl.Params.Add('Phone='+strtoint(Phone));
   CustPhoneTbl.Params.Add('Mobile='+strtoint(Phone));
   LoadRows(CustPhoneTbl);
end;

Regards,
Hüseyin

Den 06-12-2019 kl. 07:32 skrev KimHJ:
> I have a Dataset called CustPhoneTbl with this query. The Phone and Mobile are BigInt.
>
>     Select * from customer
>     where Phone={Phone=9999999997} or
>     Mobile={Mobile=9999999997}
>
> The preview works fine when either of them are correct.
>
>
>
> When I run this it will only find the row if the phone is correct.
>
> procedure TDataM.LoadCustomers(Phone: String);
> begin
>     CustPhoneTbl.Params.Clear;
>     CustPhoneTbl.Params.Add('Phone='+Phone);
>     CustPhoneTbl.Params.Add('Mobile='+Phone);
>     LoadRows(CustPhoneTbl);
> end;
>
> What is missing or is this not possible?
>
> Thanks,
> Kim
>
Fri, Dec 6 2019 10:36 PMPermanent Link

Bruno Larochelle

Hi Kim

I think you may be missing the 'quotedStr' function.. it adds the single quotes around your string.

See the EWB help file.. here is a snippet example, from the 'Using Databases / Creating and Loading Datasets' section. Note the call to 'quotedStr'. You can also do this 'manually' by putting triple single quotes (''') on each side, but the function is quite handy.


procedure TMasterDetailForm.LoadOrders;
begin
  CustomerOrders.Params.Clear;
  CustomerOrders.Params.Add('CustomerID='+QuotedStr(Customer.Columns['CustomerID'].AsString));
  Database.DatabaseName:='Production';  // Uses the default global Database TDatabase instance
  Database.LoadRows(CustomerOrders);
end;

.. hope that helps


KimHJ wrote:

I have a Dataset called CustPhoneTbl with this query. The Phone and Mobile are BigInt.

  Select * from customer
  where Phone={Phone=9999999997} or
  Mobile={Mobile=9999999997}

The preview works fine when either of them are correct.



When I run this it will only find the row if the phone is correct.

procedure TDataM.LoadCustomers(Phone: String);
begin
  CustPhoneTbl.Params.Clear;
  CustPhoneTbl.Params.Add('Phone='+Phone);
  CustPhoneTbl.Params.Add('Mobile='+Phone);
  LoadRows(CustPhoneTbl);
end;

What is missing or is this not possible?

Thanks,
Kim
Fri, Dec 6 2019 11:00 PMPermanent Link

Bruno Larochelle

having read more carefully.. i notice you are using 'BigInt', I have only ever used String for phone numbers, so my suggestion is probably incorrect.



Bruno Larochelle wrote:

Hi Kim

I think you may be missing the 'quotedStr' function.. it adds the single quotes around your string.

See the EWB help file.. here is a snippet example, from the 'Using Databases / Creating and Loading Datasets' section. Note the call to 'quotedStr'. You can also do this 'manually' by putting triple single quotes (''') on each side, but the function is quite handy.


procedure TMasterDetailForm.LoadOrders;
begin
  CustomerOrders.Params.Clear;
  CustomerOrders.Params.Add('CustomerID='+QuotedStr(Customer.Columns['CustomerID'].AsString));
  Database.DatabaseName:='Production';  // Uses the default global Database TDatabase instance
  Database.LoadRows(CustomerOrders);
end;

.. hope that helps


KimHJ wrote:

I have a Dataset called CustPhoneTbl with this query. The Phone and Mobile are BigInt.

  Select * from customer
  where Phone={Phone=9999999997} or
  Mobile={Mobile=9999999997}

The preview works fine when either of them are correct.



When I run this it will only find the row if the phone is correct.

procedure TDataM.LoadCustomers(Phone: String);
begin
  CustPhoneTbl.Params.Clear;
  CustPhoneTbl.Params.Add('Phone='+Phone);
  CustPhoneTbl.Params.Add('Mobile='+Phone);
  LoadRows(CustPhoneTbl);
end;

What is missing or is this not possible?

Thanks,
Kim
Mon, Dec 9 2019 1:35 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Kim,

<< I have a Dataset called CustPhoneTbl with this query. The Phone and Mobile are BigInt.

  Select * from customer
  where Phone={Phone=9999999997} or
  Mobile={Mobile=9999999997}

The preview works fine when either of them are correct.

When I run this it will only find the row if the phone is correct. >>

Are there any rows that match the default values for the Phone and Mobile parameters in the underlying dataset query ?

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Dec 26 2019 11:49 PMPermanent Link

KimHJ

Comca Systems, Inc

Tim Young [Elevate Software] wrote:

>>Are there any rows that match the default values for the Phone and Mobile parameters in the underlying dataset query ? <<

Tim,

It is working now.

I have this problem lately, when I update a dataset in the Datamanager and I drag a new dataset into the EWB It does not work before I restart the computer and open EWB again.


Another problem I have lately is, a program that have been working fine with Data aware grids no longer shows the data. I have to assign the dataset (Grid1.Dataset := DataModule. MyDataset) to the grid at OnFormShow even it is added in the properties at design time.

Using EWB 2.06 build 20 and EDB 2.31 build 8

Kim
Image