views:

583

answers:

2

Hi,

I am a new Database programming learner. I am using C# (.NET 3.5) along with SQL Server Express.

I am following Forms over Data Video Series from Microsoft. However, I am creating a databse, different from the one created in the videos.

In one of the tables, I wanted the present date/time to be inserted in the date column, so I am using the getdate() function as default value, which I have set using SQL Server Management Studio. When I insert new rows in this table using SQL Server Management Studio, the said column is updated fine.

However, when I use Windows form, and the auto-generated data grid for the dataset of this particular table, it does not update using the default value.

I think I am missing something in this. If somebody could point me in the right direction, it would be really helpful. Thanks.

+2  A: 

When generating your query, don't pass the date as a parameter, or alternatively, pass DateTime.Now or DateTime.UTCNow as your "current time"

Saint Domino
Thanks for answer. However if I don't pass the date as a parameter, an exception is generated, as in the database table, that date is not allowed to be NULL. From where can I specify that it is OK if in Winform, date value is not there and the server will assign it properly?
virtualmic
What's your query for inserting the data?
Saint Domino
Thanks again for answering. Nevermind, I think I got it... It was really stupid on my part... :)
virtualmic
A: 

Since you're setting the default value of the column using GETDATE() I would not even have that column in the query, let SQL keep setting it for you. I hope I'm understanding your question correctly

PsychoCoder