How does adoquery bind parameters to SQL statements ??

Source: Internet
Author: User
How does adoquery bind parameters to SQL statements ?? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061222162013160.html
For example, in an adoquery SQL statement, what if the value following 'select * From Table1 where' is a parameter? What if this parameter is an integer ??

The format function is usually used to format SQL statements.
Adoquery. SQL. text: = format ('select * From Table1 where field1 = ''% s' and field2 = % d', ['A', 12]);

For the meaning of % s and % d, refer to format help.

Adoquery. SQL. Text: = 'select * From Table1 where afield =: afield'

Adoquery. Parameters. parambyname ('afield '). Value: = xxxxxx;

Where fieldname =: myparam;


Runtime
Dataset. parambyname ('myparam'): = 1;
Dataset. open;

If this problem occurs, you should find a book faster. Isn't LZ having no Delphi book? Is it just a temporary issue of Delphi?

Thank you. I used the ": variable" method, but it does not seem to work. I am a beginner in Delphi.
Can I use adoquery. Params. parambyname ?? I don't know how to use this. Please help me more !! Thank you !!

I have an extra "medium" word and re-reply it.

The format function is usually used to format SQL statements.
Adoquery. SQL. Text: = format ('select * From Table1 where field1 = ''% s' and field2 = % d', ['A', 12]);

% S indicates that the parameter is a string, and % d indicates that the parameter is integer. For other parameters, see the help of format.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.