I created a table in my database with MYDAC components and added data. How can i extract these values that in colums from this table?
i tried these but they didn't work;
MyQuery1.Close;
MyQuery1.SQL.Text :='SELECT * FROM uyeler ORDER BY site';
Listbox1.Items.Add(MyQuery1.ParamByName('site').AsString);
MyQuery1.Execute;
uyeler = table
site = colums
Editors Note: Based on comments made to accepted answer, this question is asking how to populate a TListBox
with the data returned in a column of a query.
Your question is a little unclear. You ask how to add column data to a
TListBox
, but your code sample shows something aboutParamByName
, which looks like you're trying to assign aListBox
value to a SQL parameter.Note: Question clarified based on comment to this reply. The first code answers the question; I'll leave the second as an example for future readers because it's already written.
If you're trying to fill a
TListBox
from a database column, you need to run the query, and then loop through the data to add the column data to yourTListBox
. (You also shouldn'tSELECT *
when you're only going to use thesite
column; it means extra data is being sent from the database to the application when the data will never be used and will end up being thrown away.)This should help you get started:
If you're trying to do the second (populate a parameter with a value from a
TListBox
), this should help: