Solved

Database question

Posted on 1997-12-26
3
120 Views
Last Modified: 2010-04-04
Hi there!
I wonder, are there a way to read SQL data into a Treeview or Listview?
I've tried a lot, but do only get the SQL sentence written, instead of the extracted data.

Thanx in advance!
0
Comment
Question by:bear040497
3 Comments
 
LVL 3

Expert Comment

by:Matvey
Comment Utility
Automatic way ? No, I don't think so.

What do you mean by your last sentence ?
(Does your SQL request produces any data ?)
If you have your data from your request, what problem do you have with putting it in any visual way or into any kind of control ?
(Maybe you are new to Delphi ?)

Matvey
0
 

Author Comment

by:bear040497
Comment Utility
Nope, I've used Delphi for about 1 1/2 year, but it's just recently that I've found that there is some special data base features that I need, which I know is not originally supported by Delphi. SO, I'm NOT new to Delphi.
This is how I do it:
I use a Table, a Datasource, and a Query object.
In the query, I have this statement: select * from <table>
I do also have a Listview, which I want to place the extracted data in, but all I get, is the SQL statement.
My question is: Is there a way to get this data from the data base table into the listview? All I get now, is the SQL sentence and NOT the data.

Thanx in advance!
0
 
LVL 2

Accepted Solution

by:
mvz121697 earned 100 total points
Comment Utility
I don't know what you mean with 'special database feature', but in my opinion there is no 'data-aware' listview.
But i'll try to answer your question in 2 way's:

1)
Have you tried using a TDBgrid ? Drop a TQuery, a TDatasource and a TDBGrid on your form.
In the object-inspector, set the Datasource1.dataset to Query1, the Dbgrid1.Datasource to Datasource1, select a databasename for Query1, and fill in a 'select * from <tablename> in the SQL-property. Then set the Query1.active to True, and you'll have your data in the Grid.

2)
 I think above story was too simple (because you are not new to Delphi. So you want the data in a TListView ? May be following will get you on the way:

var tLi:tlistitem;
begin

Query1.open;
Query1.First;
While (not Query1.eof) and (not Application.Terminated) do begin
   tLI:=ListView1.Items.Add;
   tLI.Caption:=(Query1.FieldByName('FieldName').Asstring);
   Query1.Next;
 end;
end;


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

11 Experts available now in Live!

Get 1:1 Help Now