ZKM128
asked on
Unticking Allow Nulls in table design view doesn't prevent web ASP.NET form null value insert
Hello,
I have created a simple ASP.NET webform for gathering students' registration data.
When students enter their personal details on the ASPX website, the registration data goes into the 'Students' table in MS SQL Server 2008 R2 express edition.
The 'Students' table has fields 'FirstName' and 'Surname' and I have UNTICKED 'Allow Nulls' option for these fields in order to prevent students from entering their registration data without entering their name.
However, strangely I still get some blank records without any data on it. The FirstName field and Surname field are blank and in fact the record doesn't have any data/text on any of its fields at all, although I have UNTICKED the 'Allow Nulls' option for the FirstName and Surname field in the table design view.
How could this happen? ASPX online data entry error?
Thank you,
I have created a simple ASP.NET webform for gathering students' registration data.
When students enter their personal details on the ASPX website, the registration data goes into the 'Students' table in MS SQL Server 2008 R2 express edition.
The 'Students' table has fields 'FirstName' and 'Surname' and I have UNTICKED 'Allow Nulls' option for these fields in order to prevent students from entering their registration data without entering their name.
However, strangely I still get some blank records without any data on it. The FirstName field and Surname field are blank and in fact the record doesn't have any data/text on any of its fields at all, although I have UNTICKED the 'Allow Nulls' option for the FirstName and Surname field in the table design view.
How could this happen? ASPX online data entry error?
Thank you,
Does your DataSource know that you made that change?
You may need to re-configure your datasource...
Alan
You may need to re-configure your datasource...
Alan
ASKER
Hmm,, I think I didn't really understand the difference between the Null and Zero lengh string in SQL Server table.
I think the 'Students' table was getting empty records that are having Zero Length string values for all fields.
I'm not sure what actually causes the error but I want to prevent 'Students' table from receiving records with zero length string in its fields via ASPX web registration form.
How can I prevent 'Students' table from getting 'Zero length string' value records?
I think the 'Students' table was getting empty records that are having Zero Length string values for all fields.
I'm not sure what actually causes the error but I want to prevent 'Students' table from receiving records with zero length string in its fields via ASPX web registration form.
How can I prevent 'Students' table from getting 'Zero length string' value records?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
Ensure that FirstName and Surname has NOT NULL constraint.
There could be chance that while creating the table you could allow nulls. Then some records could be inserted. After that both could be set as NOT NULL.
This is the one of the possibility.
If you find junk data please do delete those rows and do ensure that NOT NULL is set for those columns.