Query results won't display in DBGrid using variable parameters

Posted on 2014-08-26
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);

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,
Question by:visionetv
    LVL 44

    Expert Comment

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

    Author Comment

    Query run without error, just won't display data in DBGrid. Hard-coded variables display without a problem

    Accepted Solution

    Solved the problem. There was a null variable in a DB column that was part of the Query.

    Author Closing Comment

    Value in the DB was the problem not the code.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now