469,927 Members | 1,910 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Blank default in XSD


I am using VB.NET 1.0 / 2002. I am having trouble setting a column
default to "" (note that "" is not the same as Null / DBNull / Nothing)
in a typed dataset (to reflect the same database default)...

Below is a snippet...

<xs:element name="Customers">
<xs:element name="CustomerID" type="xs:string"
default="bob" />
<xs:element name="CompanyName" type="xs:string"
default="" />
<xs:element name="ContactName" type="xs:string"
minOccurs="0" />

If I run the below code:

Dim x As New Dataset1()

Dim y As New Dataset1.CustomersDataTable()

Dim z As Dataset1.CustomersRow = y.NewCustomersRow()


I get an error (Column CompanyName does not accept nulls). If I change:

<xs:element name="CompanyName" type="xs:string"
default="" />


<xs:element name="CompanyName" type="xs:string"
default="Bob" />

the problem goes away (ie it correctly handles every value EXCEPT ""
(blank string)).

So my question is - how do I change the XML to reflect the fact that
the column is Required (NOT NULLable) AND has a default of "" (empty
string - not Null / DBNull / Nothing)?

Or, to state the question differently, how do I get VB.NET to put the
following line in the InitClass of the xxxDataTable class:

Me.columnCompanyName.DefaultValue = ""

(I know I can put it there myself, but then as soon as I change the XML
and regenerate the VB.NET code for the dataset my change will be lost).
I don't want to use nillable="true" since that will make it look as if
the column is NULLable (when it isn't).

Matthew Wills

Nov 21 '05 #1
2 1256

I never use that myself however because that you have no answer.

Can you not make your own class, where you Inherit that created strongly
typed dataset and than override the methode where you need that setting and
set that default there

Just a thought,


Nov 21 '05 #2

That would work - thanks for that suggestion.
Any other approach that doesn't involve inheritance?


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Paul Robinson | last post: by
19 posts views Thread by Joe Scully | last post: by
8 posts views Thread by MacDermott | last post: by
reply views Thread by Jens Mehl | last post: by
3 posts views Thread by Dabbler | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.