Solved

databases ......

Posted on 2001-08-29
10
1,775 Views
Last Modified: 2012-08-13
Hi,

I had created a database in access for customers to look some goods up of ours now we were going to buy the runtime's for access but this was way to expensive so i decided to give it a shot with delphi. I never tried databases using delphi But i managed to get something running. I used a dbgird,adotable & datasource compentent and i got one of the tables from my ms access mdb file in the grid.

I noticed some things :
in the mdb file i have several tables linked to each other (relations) but when i look at the dbgrid i only see the id's instead of what this id is represented by in another table so my question is how can i get the grid to show not the id but the name of what the id is (so it should be looked up in another table).

Another question is
how do the DBlistboxes & DBcomboboxes work ? i never could get em running, in access i had a form wich i want to remake in delphi that showed 3 listboxes each wich showed data from a table how can do this in delphi ?? i nvr could get it working (so example source code is appreciated)

also i'm looking for sites that explains this, in particular with mdb (access) files

thanks !
0
Comment
Question by:joyrider
[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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 3

Expert Comment

by:MarcG
ID: 6438507
for joining tables you need a Query component and SQL.
If you have 2 tables and they are connected with an ID, lets say table 1 contains customer name and id and table 2 contains the customer address and id, you would join with a query connect a data source to the query and connect for example a dbGrid to the database.
The SQL string would look like this
'SELECT * FROM Table1, Table2 WHERE ID1 = ID2'
0
 
LVL 3

Expert Comment

by:MarcG
ID: 6438512
and if you have a datasource that is connected to your data and then set it as datasource for you dbcombobox it should be filled with the data automatically.
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6438521
Hello

  you can do that using lookupfield

and here's free database course for delphi with access

Delphi Database Programming Course
http://delphi.about.com/library/weekly/aa010101a.htm

Best regards
Mohammed Nasman
0
Industry Leaders: 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!

 

Author Comment

by:joyrider
ID: 6438734
mnasman i already looked at that site all day & it has gotten me nowhere :( marcG thanks i got the 1st question now but i still can't get the listbox to work !!

what am i doing wrong ?
i putted a Adoqeurry datasource & dblistbox on the form
in adqeurry i made a simple querry (select customername from tblcustomers) and entered the connection string
in datasource i had set the dataset to the adoquery and in the dblistbox i had set the datasource to datasource1

after this was done i setted the active value of the adoquerry to true & ran the program all i got was an empty listbox (yes the querry returns results cause i tested it with a dbgrid)

any idea's ?
0
 

Author Comment

by:joyrider
ID: 6438741
ow yeah forgot to say i also setted the datafield value to customer name in the dblistbox
0
 

Author Comment

by:joyrider
ID: 6438753
ow yeah forgot to say i also setted the datafield value to customer name in the dblistbox
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6439090
Hi joyrider,

I don't know if this is still applicable or not, but a few years ago, the company I was working for wrote an app in Delphi which used Access as it's DB.  After completing the app, my R&D "Manager" discovered that we could not distribute the application legally without having either VB or Access installed on the clients PC (or obtain a license to legally install the drivers onto their PC).  This was a real pain.  What we had to do was ship a copy of Access 97 with our app to comply with the license.

I would strongly suggest you find out if this still applies, and if it does, perhaps you should look at a different DB - such as Interbase (which is better than Access anyway).

With your question about the listboxes and comboboxes, try this:

Drop a TDatabase component onto the form (or TADOConnection).  Connect it to your Access database.  Drop a TTable (or TADOTable) onto the form and link it to the TDatabase (or TADOConnection depending on the way you went).  Next, drop a TDatasource component onto the form and link it to your Table component.

Next, drop a TDBLookupComboBox onto the form.  Set it's ListSource property to the TDataset.  Choose a table from the ListField and KeyField properties and away you go.  The same applies for a TDBLookupListBox.  It had me fooled for ages too :)

Cheers!

Stu.
0
 
LVL 3

Accepted Solution

by:
MarcG earned 50 total points
ID: 6439516
just read this example in Delphi help on DBListBox
"
while not Table2.Eof do begin

  DBListBox1.Items.Add(Table2.FieldByName('Country').AsString);

  Table2.Next;

end;"

It seems to me you have to fill the box 'manually'.
0
 

Author Comment

by:joyrider
ID: 6439926
ah ok hehe thought it would do it automaticly :)

thanks u also helped me with question 1 so u get the points :)
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6440047
That's why you use the DBLookupListBox or DBLookupComboBox!  It does the adding for you automatically!

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

729 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