johnp Posted February 26, 2013 Posted February 26, 2013 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) Quote
mmurgas Posted February 26, 2013 Posted February 26, 2013 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 Quote
mierlp Posted February 26, 2013 Posted February 26, 2013 Your select statement was already correct but mist some '', see below Select * from Product Where Name LIKE ''' + '%' +UniEdit_Search.Text + '%'' Order By Name Quote
johnp Posted February 27, 2013 Author Posted February 27, 2013 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. Quote
Ronak Posted February 27, 2013 Posted February 27, 2013 Here is on demo, may be usefull Condition builder works fine with MSSQL Query, for query other then MSSQL you may need to correct the parsing procedure QBFrame.rar Quote
mierlp Posted February 27, 2013 Posted February 27, 2013 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.