Solved

databases ......

Posted on 2001-08-29
10
1,774 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
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!

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
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…
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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