Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

This is Phani Kumar i am developing an application, I have textbox in an application some time i enter text into textBox but some times, i enter Data and but sometimes, I donot enter data. But when i do not Enter Data, when i save it in Sqlserver DataBase it should be saved as "NULL"

Kindly Reply Me as Soon As possible
Posted

Use System.DBNull whenever you have that case and then it will save NULL in your database.
 
Share this answer
 
Check using

if(String.IsNullOrEmpty(YourTextbox.Text))
{
     //Now set data as DBNull.Value
}


It will save Null in database.

Also if you dont specify the value in insert statement it will automatically set itself as null by default.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900