How are you retrieving the data? Are you using a DataSet, a reader? or
other means?
Maybe it doesn't matter much because you're really just stuck with using
some conditional checking. A common method I use for strings is, assuming
dr is a DataRow from my DataSet.Table
myString = dr.IsNull("myColumn") ? String.Empty : dr["myColumn"];
and for int:
myInt = dr.IsNull("myColumn2") ? 0 : dr["myColumn2"];
There are a lot of reasons for using nulls in data. It's not just a
leftover condition of "old data". For instance, dates that haven't been
assigned. You don't want to have to compare every date against January 1,
1753.
It's best to test for null on every field that allows nulls because someone
somewhere and somehow will get a null in even if you try to code them out.
Hope this helps,
Dale Preston
MCAD, MCSE, MCDBA
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
I know the reason why I get an error when the fields are set to null, but
I'm working with old data that contains them. Any quick fixes? was hoping to
avoid writing out every field in sql statement for ISNULL and avoid the long
check on the make equal to value. Ideas?
Sql statement (I know I could use parameter):
"SELECT * FROM COMPANY_INFO WHERE COMPANY_ID = '" & usercompanyid & "'"
Setting value example:
txtcompanyid.Text = "" & memberdata("COMPANY_ID")
Thanx!