Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Default value in SQL Db

Author  Topic 

tn3003
Starting Member

1 Post

Posted - 2008-05-11 : 06:30:07
I am using SQL Express and Expression Web. A table in my db records holiday requests and has a status field. I want this field set to a default value of 1. The field in SQL (Default Value/Binding) is set to 1 and displays ((1)). If I enter a row manually, it works fine. However, the web form posts data to the database but this particular field results in NULL? I've had to allow NULLS on this occasion to troubleshoot to this point whereas normally for this field NULLS would not be allowed. Any idea why this is behaving as so?

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-05-11 : 11:06:12
Because your webform is supplying the parameter with a NULL value.
In a sense, it is specifically telling the database to store NULL, which overrides the default set for the column.
You can fix your webform, or you can put a trigger on the table to convert NULL values to your default.

e4 d5 xd5 Nf6
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-11 : 13:05:19
You must modify your webform to not pass any value for field for which you want default value to be taken.
Go to Top of Page
   

- Advertisement -