For new database programming, we may have some questions about "NULL". For example, if all the data in a new table is displayed as <NULL>, after manually adding and deleting text, it becomes blank again. A string-type field is not explicitly filled in, but not equal to ""; ADO is used. NET value from the database, an error occurs every time there is a <NULL> ...... This requires us to correctly understand several different "null values" in. NET and SQL Server ".
1. The true null value, that is, "No input value", can appear in most types of fields (if there are no other constraints). It is expressed as null in SQL server, displayed as <NULL>. In the SQL server Enterprise Manager, press Ctrl + 0. It corresponds to System. DBNull. Value in. NET. In the T-SQL command, to determine whether a value is null, use "is null" instead of "= null"; to handle a null value, there is an ISNULL function that replaces null with the specified value. Use ADO. the null value obtained from the database cannot be automatically converted to a null string or a Nothing. You must manually check the value if System is obtained. DBNull. value is assigned to the Data Object Nothing or other custom meaningful values.
2. A null string (zero-length string) appears only in a string type (such as nvarchar) field. It is expressed as ''in SQL server and displayed as blank, manually enter a cell in the SQL server Enterprise Manager. It corresponds to System. String. Empty in. NET, which is commonly used "". Processing empty strings in T-SQL commands is no different from processing general strings. The Null String obtained from the database using ADO. NET is no different from the general string.
Related concepts include VB. the Nothing in NET corresponds to C #. NET null (note that this null is C #. NET, rather than SQL Server), they are in. NET indicates that no empty reference of any object is referenced. When importing SQL server, according to different context, it may be stored as a true null value (for example, when updating a string field value ), it is also possible to call the custom default values in SQL server (for example, to pass a stored procedure parameter with a default value), or it may be caused by the failure of type conversion. NET exception. Therefore, when using ADO. NET to store data to SQL server, use Nothing with caution.