Ok, the weblog is still giving some problems. My database table fields are set to not allow nulls but I'm stil able to insert data into the fields. Now everything works fine on my computer but craps up when I upload the project.
I need some help.I think I'm going to just host my weblog on my on computer at home. EhostingBiz.com, is just not doing it for me. I create my tables and set the columns to not null, but they still allow null values. Everything works on my computer, so I know its not my code. I'm going to bed now.
Have you tried another host - a free one just to compare whether its your current.
No, I have not tried another host. Thats gonna take too much time.
All I wanna know is. How is it possible to insert null values in columns that are set to not allow null values.
Its not possible - except you can add checks which only apply to new data ignoring previous rows but cannot recall if this can apply to nullability!!!
I can't believe this can happen against the way SQL Server works.
Can you post you tabel schema?
I would bet that it might be a database setting that is doing this for you. I would go to the database forum and ask why this isn't working like you want it.
I always verify the data I am throwing at the database anyway, I can usually head off reads and writes that won't work based on the rules I have set. This first acts like a filter, and also as a performance enhancement because you don't have to needlessly access the database unless you are 95% sure the data is good.
If I have time today, I will check into whether or not I can do this on my DB.
Also, it would be helpful if you generated a setup script of you database and posted it here. We might be able to find a problem in there.
Originally posted by hellswraith
I would bet that it might be a database setting that is doing this for you. I would go to the database forum and ask why this isn't working like you want it.
I always verify the data I am throwing at the database anyway, I can usually head off reads and writes that won't work based on the rules I have set. This first acts like a filter, and also as a performance enhancement because you don't have to needlessly access the database unless you are 95% sure the data is good.
If I have time today, I will check into whether or not I can do this on my DB.
Also, it would be helpful if you generated a setup script of you database and posted it here. We might be able to find a problem in there.
I think thats what is happening. Another problem I have is that my RequiredValidator controls wont fire when I upload my project. As I've said before everything works fine on my computer, so this is kinda strange. To force the RequiredValidators to fire, I had to put my code in an if(Page.IsValid) block. I did'nt really want to do that since the page is posting back.
Here is the script.
If you select NO to allow nulls then you will have to supply data to be inserted into the field when a record is inserted. If you have no data to populate the field then sometimes an empty string will do.
But the easiest way I have found is to supply a default value for the field. For string fields and empty string will do. For numerics a zero. For date fields you can use GetDate() as the default or supply a non-sense date like '01-01-1900'.
And a null is a null is nothing...
Should'nt the DB throw an exception if the value is null? If I enter data from enterprise manager and leave a column empty, an exception is thrown.
OK, I am not sure what columns your having problems with. Here is what I see from the scripts...
URL and Email in the comments table are set to ALLOW null values. If these are the columns that are giving you trouble, then you need to switch them to Not Null.
Another thing I have found with ASP.Net is that a empty text box will return a empty string instead of a null value if there is nothing in it. You may be allowed to enter the data because the empty string is being passed therefore it isn't really a null value.
Originally posted by hellswraith
OK, I am not sure what columns your having problems with. Here is what I see from the scripts...
URL and Email in the comments table are set to ALLOW null values. If these are the columns that are giving you trouble, then you need to switch them to Not Null.
Another thing I have found with ASP.Net is that a empty text box will return a empty string instead of a null value if there is nothing in it. You may be allowed to enter the data because the empty string is being passed therefore it isn't really a null value.
The url and email columns are suppose to be like that. I'll have to check out what you said about the empty text box. Thanks for help.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment