Solved

Delphi 7 : Lookup Field?

Posted on 2007-11-19
17
1,108 Views
Last Modified: 2013-11-23
Hi Experts,

I have an TDBGrid and would like the use to be able to pick from a dropdown in the list.
For example:

Table1:
ColorID INT PK
ColorCode VARCHAR(10)
Description VARCHAR(100)

Table2:
VehicleID INT PK
ColorID INT
RegNumber VARCHAR(20)


When inserting a new row in the DBGrid for Table2, I would like to user to be able to select from dropdown in grid from all the available colorcodes and after selecting the ColorID should be saved in this table.

I managed to get what I am looking by means of creating a new lookup field on my ADOTable Component for Table2. But when inserting a new row I receive the following error:

"raised exception class EOleException with message 'An unkown error has occurred.' Process stopped...."

Please advise.
0
Comment
Question by:Marius0188
17 Comments
 
LVL 21

Assisted Solution

by:developmentguru
developmentguru earned 150 total points
ID: 20312096
We would need to see your code for starters.  There is nothing wrong with how you are handling the lookup field, that in itself should not cause an error.  I suspect that something was missing in how it was set up.  Can you show us a simplified example?
0
 

Author Comment

by:Marius0188
ID: 20312820
Here is a screenshot of my setup:
http://www.medalware.com/delphi_lookup.JPG

I use a normal TDBGrid and TADOTable components.

Thanks!
0
 
LVL 18

Assisted Solution

by:Johnjces
Johnjces earned 150 total points
ID: 20315434
I am confuised, but that is pretty normal for me...

Are you storing in your dataset the color as a string name such as clRed, or clBlack or are you storing the actual color identifier, which will be a hex value such as $000000FF, (decimal 255 which is clRed) .

ColorID as an Int sounds OK if you are storing the color value, but I do not know about what you are storing in ColorCode and if that is like clRed.

Not sure if it is a table/database issue or some other code part failing when getting the color.

A code snippet or two will really be helpful as developmentguru has suggested. A picture can be worth a thousand words, but...

John
0
 

Author Comment

by:Marius0188
ID: 20319069
I have build a demo app using Firebird database and Interbase components.
I have created a lookup table exactly as I have done with the ADO table components and it is WORKING here.

I guess there is something else about the TADOTable component.
Let me see if I can provide you with a demo.


Cheers
0
 

Author Comment

by:Marius0188
ID: 20319183
Ok I have produced a demo for you:
http://www.medalware.com/demo_lookup.zip

Just connect both TIBDatabase & TADOConnection components to the databasis that is in a subfolder.
1 x Firebird DB
1 x MS SQL MDF DB

The firebird is working 100%.
The SQL db is giving me that nasty exception.


Thanks in advance!

0
 

Author Comment

by:Marius0188
ID: 20319221
It looks like a bug in ADO.
http://qc.codegear.com/wc/qcmain.aspx?d=46248

Is there any work arounds?
Where can I get the latest Delphi 7 updates?


Thanks!
0
 

Author Comment

by:Marius0188
ID: 20319310
Can one connect to SQL 2005 db without using ADO components?
Is there any other good alternative components or methods one can try?
0
 
LVL 8

Accepted Solution

by:
RickJ earned 200 total points
ID: 20331714
Hello marius0188,
I downloaded and tried your example and it works fine for me.
Guessing it may be something that was fixed with the delphi 7 service update 1. Do you have that installed?
I think you need to be a registered user to download it.

Rick.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Marius0188
ID: 20332773
Yes I do have that update.
But if I remember correctly, when installing that update it prompt to notify me about missing files where after I just clicked ignore. Maybe it has something to do with that.

Mmmmh, I wonder if I can just update the ADO dcu's etc by getting them from you.
Will that not work?
0
 
LVL 8

Expert Comment

by:RickJ
ID: 20333275
Much cleaner to get your intall to work correctly, but worth a shot I guess.
Would back up before attempting.
Here you go.
http://www.logancontracting.com.au/ado/ado.zip
0
 

Author Comment

by:Marius0188
ID: 20333516
Nope, still not working.

Are you also using Delphi 7 Enterprise?
0
 
LVL 8

Expert Comment

by:RickJ
ID: 20333530
Delphi 7 pro. I would have thought the ado stuff would have been the same. But I could be wrong.
Not sure how else I can help you...
0
 

Author Comment

by:Marius0188
ID: 20333790
You don't think it might be the TDBGrid component?
Maybe you must sent me your source and let me try that.

0
 
LVL 8

Expert Comment

by:RickJ
ID: 20336974
I still think getting your install correct would be a better way to go. But again,
Here you go.
http://www.logancontracting.com.au/ado/dbgrids.zip
0
 

Author Comment

by:Marius0188
ID: 20337406
Yip, after this one I will go for re-install and then apply that 7.1 update.
But need a quick fix because installing all my components from start takes 1-2 days.

Enjoy
0
 

Author Comment

by:Marius0188
ID: 20337417
Ok but another thing is:
It is only in the compiler (IDE) that I get the exception EOleException.

When running outside the IDE no problem.
Should I still be worried?
0
 

Author Comment

by:Marius0188
ID: 20372089
Ok I will accept that this might be an installation problem.
Have not tested yet but will try to re-install as soon as I have time available.

Lets split the points....

Thanks to all!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IExtractImage Delphi 14 201
add combobox item based on numbers 9 122
Convert GUI app into console app for Win32 Env 5 78
How to define IfThen functions in one common unit? 4 44
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now