Solved

Database question

Posted on 1997-12-26
3
126 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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

628 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