?
Solved

Query results won't display in DBGrid using variable parameters

Posted on 2014-08-26
4
Medium Priority
?
235 Views
Last Modified: 2014-09-01
Hi Experts;

Using a Delphi 7 ADOQuery component my application displays data results using hard-coded values in the Query but apparently will not recognize the same values as variables converted to integers from two TEdit controls

Code snippet - OnClick Event...
Query1.Parameters.ParamByName('RegID').Value := StrToInt(Edit1.Text);
Query1.Parameters.ParamByName('BatNum').Value := StrToInt(Edit2.Text);
Query1.Open;

Code snippet from Query:
WHERE TenderEntry.BatchNumber = :BatNum AND Batch.RegisterID = :RegID
With the Parameters 'BatNum' and 'RegID' in Query1 no results are displayed in the Delphi DBGrid.

Using hard-coded values without Parameters the results display without issue.

Code snippet from Query:
WHERE TenderEntry.BatchNumber = 1 AND Batch.RegisterID = 1

I need help in getting the Query to recognize the variable parameters from the TEdit boxes.

Any thoughts or a solution will be greatly appreciated.

Thank you,
Visionetv
0
Comment
Question by:visionetv
  • 3
4 Comments
 
LVL 53

Expert Comment

by:Vitor Montalvão
ID: 40288107
The query runs with error or just doesn't return rows?
0
 

Author Comment

by:visionetv
ID: 40288468
Query run without error, just won't display data in DBGrid. Hard-coded variables display without a problem
0
 

Accepted Solution

by:
visionetv earned 0 total points
ID: 40289187
Solved the problem. There was a null variable in a DB column that was part of the Query.
0
 

Author Closing Comment

by:visionetv
ID: 40296329
Value in the DB was the problem not the code.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

862 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