By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,903 Members | 2,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,903 IT Pros & Developers. It's quick & easy.

Null value in a string not allowed in database

P: n/a
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
*-----------------------*
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If the field is nullable then this is how you would do it.
ZeroLenthStringToNull = System.DBNull.Value

Chris

"rishaan" <ra******@gmail-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
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
*-----------------------*

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.