Link to home
Start Free TrialLog in
Avatar of ZKM128
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.

User generated image
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,
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Please look at the script of the table that you have created.

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.
Does your DataSource know that you made that change?
You may need to re-configure your datasource...

Alan
Avatar of ZKM128
ZKM128

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?
ASKER CERTIFIED SOLUTION
Avatar of Alan Warren
Alan Warren
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ZKM128

ASKER

Thank you.