Strange problem while inserting row into table.

  • Thread starter Thread starter trialproduct2004
  • Start date Start date
T

trialproduct2004

Hi all,

I am facing one problem while inserting data into table through windows
application.

I am having one table in sql server containing one field for which i
set default value as 'getdate()' while designing that table only.

So when i add reords to that table through sql query analyser no need
of specifying this field.

But when i try to insert data into this table through windows
application it is not inserint current date time into table.

If i set this column as primary key in sql server itself it is working
properly.

But without setting column 'createdon' as primary key , in c#
application i need to set datatable.column["datetime"].defaultvalue as
current date time even though for this column i set default value in
sql server while designing itself. I am not getting why this is
happening.

Can someone shed some light on it.

Thanks in advance.
 
In the SQL table definition, do NOT allow NULL. This will cause the default
value to be inserted.
 
Hi,

thanks for your reply.

But i have already done that still it is not working.

Is there any other way of doing this?.

Thanks.

Brad said:
In the SQL table definition, do NOT allow NULL. This will cause the default
value to be inserted.
--
Brad

"Software is like melted pudding..."


Hi all,

I am facing one problem while inserting data into table through windows
application.

I am having one table in sql server containing one field for which i
set default value as 'getdate()' while designing that table only.

So when i add reords to that table through sql query analyser no need
of specifying this field.

But when i try to insert data into this table through windows
application it is not inserint current date time into table.

If i set this column as primary key in sql server itself it is working
properly.

But without setting column 'createdon' as primary key , in c#
application i need to set datatable.column["datetime"].defaultvalue as
current date time even though for this column i set default value in
sql server while designing itself. I am not getting why this is
happening.

Can someone shed some light on it.

Thanks in advance.
 
Back
Top