Reputation: 3213
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.
Upvotes: 0
Views: 1487
Reputation: 10765
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
Upvotes: 0
Reputation: 1412
When generating your query, don't pass the date as a parameter, or alternatively, pass DateTime.Now or DateTime.UTCNow as your "current time"
Upvotes: 2