Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C++ Builder5: problem with query

Posted on 2002-07-17
7
Medium Priority
?
213 Views
Last Modified: 2010-04-01
I run this piece of code:

QR->Close();
QR->SQL->Clear();
QR->SQL->Add("SELECT somefields FROM sometable");
QR->Open();

and QR->open throws a mysterious exception: "QR: Field OTHERFIELD not found". Its mysterius, because OTHERFIELD is not presend in 'somefields'...

Any ideas how should I solve this?
0
Comment
Question by:Robson
[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
  • 3
7 Comments
 
LVL 4

Author Comment

by:Robson
ID: 7159727
Additional info: table 'sometable' contains field 'OTHERFIELD'.
0
 
LVL 1

Accepted Solution

by:
Boomers earned 600 total points
ID: 7160211
Hi Robson,

His QR an object TQuery on your Form or did you code it with the TQuery *QR;
If it is on a form. Make sure that when you dbl-click on the object to look at the field, you do not see the field OTHERFIELD.

Your field on your SQL query and your field on your object should be the same.

Hope this helps!!!
0
 
LVL 4

Author Comment

by:Robson
ID: 7161608
Hmm, just how you suspected: the query is included on the form with all fields from sometable. Maybe there is a way to temporary disable them? QR->DisableControls don't work....
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!

 
LVL 1

Expert Comment

by:Boomers
ID: 7161985
Hi Robson,

    I don't think you can disable theses TField but i'll look at it. You could delete all the field from the TQuery object and change your reference to theses field using the following syntax:

String a;
a = QR->FieldByName("Field1")->AsString;

This way the TTable will only contains the field that are within your SQL statement. The only thing is that no TField will be accessible since they are based on a SQL Statement that is created at run time.

Let me know if this helps!!!
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7163687
You can change the Required property of the field in question, either in code or through the Object Inspector. If you're using using a TQuery, you might as well just delete all the fields, anyway. You can always just include them in your SQL statements... Food for thought.


Good luck!!
0
 
LVL 4

Author Comment

by:Robson
ID: 7171474
Points go to Boomers who firs diagnosed my problem.

Thanks for your Comment, DrDelphi. I checked Required property and for all fields it's set to false :-( It confused me even more, but I haven't created this form and I'm not going to redesign it.
0
 
LVL 1

Expert Comment

by:Boomers
ID: 7171720
Thanks for the A grade Robson.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

670 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