Solved

Database question

Posted on 1997-12-26
3
124 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…

734 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