Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with ADOQuery component

Status
Not open for further replies.

dsfii

Programmer
Sep 14, 2004
7
0
0
US
Hi guys, I have a simple ACCESS database data.mdb that I want to be able to communicate with in my program (using BCB 5 Ent). I set it all up using the ADOConnection component to connect to the database, then I am using the ADOQuery component to post SQL commands to the database. This is working great and all but,, How the heck can I work with my results from the ADOQuery?

Say I run this statement "SELECT * FROM datatable WHERE rats='cheese'"

Okay great, works, but I want to work with the results in my coding - not on a DBGrid. I want to be able to chop at the results with my code and display what I want to the end user in my own Memo or something...

For instance, say I want to display on a Label that 5 of the results contain the letter "A" in the name column.
 
Guess I might have anserwed myself! This is bout all I can get to work, althought I'd like to address the fields by name and can't get that to work yet.

ADOQuery1->Fields->Fields[1]->AsString;
 
The easiest way is to link a dataset to the query. That way you can do "MyADODataSet->FieldByName("MyField")->AsString;" or however you want.

I prefer to use the dataset anyway. I can get the dataset to do a query by using its CommandText.

James P. Cottingham
-----------------------------------------
[sup]To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.[/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top