datacolumn extendedproperties - are they always available?

B

Bernie Yaeger

I'm coming to a sad conclusion - it appears that datacolumn
extendedproperties only work if the datatable is part of a strongly typed
dataset.

Now this sounds odd, but I can't get this to work:

Dim davendor As New SqlDataAdapter("select vname, saddr, saddr2, scity,
sst, szip, baddr2 from vendor order by vname", oconn)
Dim dsvendor As New DataSet("vendor")

davendor.Fill(dsvendor, "vendor")

dsvendor.Tables(0).Columns("saddr2").ExtendedProperties.Add("nullValue",
String.Empty)

When the code gets around to this (in an 'i' loop),

glfs_addr2 = dsvendor.Tables(0).Rows(i)("saddr2")

it fails if the value of saddr2 is null, but ok if otherwise. The idea of
the extendedproperties that I had was to convert null to an empty string and
thus not fail here. I know I can solve this with a

If Not IsDBNull(dsvendor.Tables(0).Rows(i)("saddr2")) Then

but this is exactly what I was trying to avoid.

Thanks for any help.

Bernie Yaeger
 
K

Ken Tucker [MVP]

Hi,

Did you try to set the defaultvalue for the datacolumn?
dsvendor.Tables(0).Columns("saddr2").DefaultValue = ""

Ken
 
B

Bernie Yaeger

Hi Ken,

Tx for your reply.

What I am really trying to do is set up a null conversion, such that if a
null value is encountered, it would return instead string.empty (or as
appropriate for the given data type). I think that it's continually failing
because I am not using a strongly typed dataset, there is no xml and there
is no xsd to make this work. I could of course write to xml and then write
the schema, but I might just as well go all the way and create a strongly
typed dataset, but I was hoping to control null values with regulare ol'
datasets.

Guess I back to 'if not isdbnull(blah blah blah

Bernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top