Jump to content

Query help


johnp

Recommended Posts

I am having trouble in uniGUI with some query results. For some reason if a my edit box contains numeric data I cannot get query results from a character field with numeric data, or results on a numeric field. I am using these statements to add to my SQL string.

 

QryReference.SQL.Add('Select * From Orders WHERE REF = ' + QuotedStr(UniEdit1.Text));

 

or

 

QryReference.SQL.Add('Select * From Orders WHERE REF like ' + QuotedStr(UniEdit1.Text));

 

If my data and UniEdit box contains the data 'ABC' for example I get results for ABC or any other test characters I try that are in the table

 

If my data and UniEdit box contains the numeric data  such as '123' for example I get NO results.

 

Is this a bug or am I missing something for numbers?

 


John P (Canada)

 

Link to comment
Share on other sites

I personally prefer the querys with parameters, have never given me my mistake and order code

 

    DM.TablaX.Close;

    DM.TablaX.SQL.Clear;

    DM.TablaX.SQL.Add ('SELECT *');

    DM.TablaX.SQL.Add ('FROM mytabla');

    DM.TablaX.SQL.Add ('WHERE Cod LIKE: param1');

    DM.TablaX.Parameters.ParamByName ('param1'). Value: = '%' + trim (edit.Text) + '%';

    DM.TablaX.Open;

 

regards
Link to comment
Share on other sites

The use of the parameter example worked for me.  I could not get to parse when using the wild cards in the other example, and when I did it showed all records with use of both wild cards, which I must not be putting my string together just right.

 

Thanks for such great support and involvement of this board!

 

John P.

Link to comment
Share on other sites

Hi John

 

The example in my post  is works becaus because i use it a lot in my applications

It show all the records which contains the entered characters ...if you search

for the the works: Excel end when you enter : cel if finds all the records

with this combination. It's how you use the wildcards..

 

The example is based on MySql so it's possible there can be a other

behavoir if u use a other database.

 

Regards Peter

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...