Solved

Database question

Posted on 1997-12-26
3
123 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
ID: 1354623
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
ID: 1354624
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
ID: 1354625
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
FMX enumerated colours 2 119
Using idhttp to login to instagram 2 106
how to send memory stream from ics Client To ics server ? 11 139
Delphi...Split view - idea? 1 90
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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