B
Bob Day
Using VS 2003, VB.net and SQL MSDE...
This is driving me nuts!
I would love to find a simple way to translate any column with a <NULL>
value that is a datatype string to a string.empty (i.e. ""). Is there any
command that says "To make life easy, automatically translate any <NULL> in
a STRING datatype column to String.Empty" when it is FILLed from a
DataSource?
The answer I suspect is no.
I have posted many posts to these boards on this subject, and have not
gotten an answer that is feasible.. Since VB.net fails when you try to FILL
a column that has a <NULL> value, you either have to 1) confirm it is not
<NULL> for each column before you FILL it to a DataSet or 2) prevent <NULL>
from ever getting in your datasource to begin with. Both of these take an
extraordinary amount of code, which could easily break if field names
change, etc.
1) confirm each column is not null before you FILL. This works, but
requires a lot of code (for each column read).
Basically, check each column with the .IsColumn1Null, and FILL it only if
false, but this would be a lot of code required for every column.
2) One suggestion:
"You can use isnull in the sql select statement. It
returns what you want if the cell is null. i.e., isnull
(inCareOf, '')"
I use the Component Designer/Query Designer, which makes use of the above
very difficult. You manually have to change each column name, defeating the
power of the Query Designer to make change quickly in the future. Any other
way of doing this?
3) Another suggestion:
"Public Sub StringNullHelper(arg As Object) As String
If IsDbNull(arg) Then Return String.Empty
Return Cstr(arg)
End Sub"
The problem here is this assumes you already have arg to pass to this
method. The Fill command fails on a column that has a <NULL> value, so you
never get arg to use this method.
4) Using Sever Explorer, Table Designer, designing each column with a
default value of ('') for string data type should avoid a null when the row
is added to the DataSource and updated with a column that has no value in
it. This does not work as documented at all, and is a bug that should be
resolved.
This is really causing a lot of problems, and I cannot believe there is not
a relatively simply way to do it.
There has to be an easier way!!!
Any ideas?
Thanks!
Bob Day
This is driving me nuts!
I would love to find a simple way to translate any column with a <NULL>
value that is a datatype string to a string.empty (i.e. ""). Is there any
command that says "To make life easy, automatically translate any <NULL> in
a STRING datatype column to String.Empty" when it is FILLed from a
DataSource?
The answer I suspect is no.
I have posted many posts to these boards on this subject, and have not
gotten an answer that is feasible.. Since VB.net fails when you try to FILL
a column that has a <NULL> value, you either have to 1) confirm it is not
<NULL> for each column before you FILL it to a DataSet or 2) prevent <NULL>
from ever getting in your datasource to begin with. Both of these take an
extraordinary amount of code, which could easily break if field names
change, etc.
1) confirm each column is not null before you FILL. This works, but
requires a lot of code (for each column read).
Basically, check each column with the .IsColumn1Null, and FILL it only if
false, but this would be a lot of code required for every column.
2) One suggestion:
"You can use isnull in the sql select statement. It
returns what you want if the cell is null. i.e., isnull
(inCareOf, '')"
I use the Component Designer/Query Designer, which makes use of the above
very difficult. You manually have to change each column name, defeating the
power of the Query Designer to make change quickly in the future. Any other
way of doing this?
3) Another suggestion:
"Public Sub StringNullHelper(arg As Object) As String
If IsDbNull(arg) Then Return String.Empty
Return Cstr(arg)
End Sub"
The problem here is this assumes you already have arg to pass to this
method. The Fill command fails on a column that has a <NULL> value, so you
never get arg to use this method.
4) Using Sever Explorer, Table Designer, designing each column with a
default value of ('') for string data type should avoid a null when the row
is added to the DataSource and updated with a column that has no value in
it. This does not work as documented at all, and is a bug that should be
resolved.
This is really causing a lot of problems, and I cannot believe there is not
a relatively simply way to do it.
There has to be an easier way!!!
Any ideas?
Thanks!
Bob Day