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

Blank default in XSD

P: n/a

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
Share this Question
Share on Google+
2 Replies

P: n/a

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

P: n/a

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.