?
Solved

ado: set default field values

Posted on 2003-03-25
6
Medium Priority
?
525 Views
Last Modified: 2010-05-18
hi all,
i have a table with some default values
for example "IsMember" set to False.

now, when i insert a NEW record (insert mode) in my form and uses TDBCheckBox
the DBCheckBox is grayed (and checked) as if the initial value is NULL.
how can i make the DBCheckBox to set the default values from the DB, so it is marked as the default?

hope my queston is clear.
0
Comment
Question by:morgantop
[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
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8203552
usual dafaults are only set
when the record is being about
to be inserted into the db and
the user did not providing a value
or a explicit NULL -> on post

usual most frontends (also delphi)
are giving an explicite NULL to the DB,
if the user didn't enter a value,
but you can give at TField-Level
a DefaultExpression -> property,
(on some databases this default
is read out from the db automatically,
guessing not with ADO (never tested))
which is applied on post.

if you want the fields prepared
with a defaul-value, then u have
to do it byself, using the
afterInsert-event of the dataset.

meikl ;-)
0
 
LVL 1

Author Comment

by:morgantop
ID: 8210662
hi kretzschmar,

>if you want the fields prepared
>with a defaul-value, then u have
>to do it byself, using the
>afterInsert-event of the dataset.

problem is that i'm checking the dataset.Modified flag.
if i change dataset on afterInsert event, Modified is set to true.
is there a way to clear the Modified flag, without posting?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8210837
>is there a way to clear the Modified flag,
>without posting?

nope, its a readonly-property,
how or why do you check this flag?
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!

 
LVL 1

Author Comment

by:morgantop
ID: 8211260
when user addes new record,
i open a modal form (with db-awrae controls bound to a dataset) set dataset.Append and the user fills the info.

if he press 'cancel' button i do dataset.Cancel
if he press 'ok' i check if the dataset.Modifyed only then make dataset.Post (and other sql inserts)

this works well but my DBCheckBox's are allways checked+grayed (the initial problem)
i dont remember having such "problem" with paradox.

you see my problem?

thanks.
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 500 total points
ID: 8211622
well, a trick

type
  TCrackDataSet = Class(TDataSet);

procedure TForm1.Button1Click(Sender: TObject);
begin
  TCrackDataSet(Table1).SetModified(False);
end;

just use it in the afterInsert-event,
to reset the modified flag to false

hope it works for you

meikl ;-)
0
 
LVL 1

Author Comment

by:morgantop
ID: 8212507
briliant as usual :)
0

Featured Post

Independent Software Vendors: 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

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 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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

770 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