Null value in a string not allowed in database

  • Thread starter Thread starter rishaan
  • Start date Start date
R

rishaan

I have a question about inserting null values in .Net into a column.
As you know the text boxes in .Net have a defined data type of string.
Let us say, on a form the user did not enter a certain text box
(Address_2 or something). If this column in MS Acess database was
defined as AllowZeroLengthString=False but the column is nullable.
How will you insert a null value into the column?

In VB 6.0 ,it works like this:

Function ZeroLengthStringToNull (strIn$)
if strIn="" Then
ZeroLengthStringToNull=Null
else
ZeroLengthStringToNull=strIn
End Function

Function is returning the variant data type, that is why I am able to
assign NULL to it.

Is object type the only solution to this problem...
Any ideas

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
If the field is nullable then this is how you would do it.
ZeroLenthStringToNull = System.DBNull.Value

Chris
 
Back
Top