Page 1 of 1

how to post a query with default value field?

Posted: Fri 25 Feb 2011 05:44
by sefeng1982
hello,erveryone~
i met a problem about post a query.
questiontable has the follow column:
code identity(1,1)
question_id int not null
question_name varchar(500) not null
description varchar(500) null
ztime datetime default(getdate()) not null
status bit default(1) not null

here is the component:
selectuniquery.sql.text:='select * from questiontable'
selectuniquery.updateobject:=uniupdatesql;
updatesql.insertobject:=insertuniquery;
insertuniquery.sql.text:='insert into questiontable (quesion_id,quesiton_name) values (:quesiont_id,:question_name)'

selectuniquery.append;
selectuniquery.fieldbyname('question_id'):='1';
selectuniquery.fieldbyname('question_name'):='question1';
selectuniquery.post;

the error is field ztime must has value ~~~
how can i post the dataset ?

sorry for my poor english~~

Posted: Fri 25 Feb 2011 09:02
by AlexP
hello,

To resolve the problem you should set the RequiredFields property to false like:

UniQuery.Options.RequiredFields := false;