Typed Dataset: Stetting DataColumn-values

  • Thread starter Thread starter Michael Maes
  • Start date Start date
M

Michael Maes

Hi,

How do you set the settings (like MaxLength, ReadOnly, DefaultValue, ....) in a DataColumn of a Typed Dataset.
I know you can do this in Run-Time (eg: dataset.datatable.datacolumn.MaxLength = 4) but I want to do this in the XSD Schema-Designer (or XML-file)

Thanks for any hint,

Michael
 
Hi Michael,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to set the properties of a
DataColumn (like MaxLength, ReadOnly, DefaultValue, ...) at design time in
the DataSet schema. If there is any misunderstanding, please feel free to
let me know.

Gerenally, we can set most properties in schema. Here are the steps:

1. Open the DataSet schema design view, and click on one of the elements.
The element stands for a DataColumn.
2. In the properties windows, we can set attributes for that element. If
you cannot see the properties windows, please select View/ Properties
Window from the main menu.
3. The "default" attribute maps to the DefaultValue property and the
ReadOnly attribute maps to the ReadOnly property. Or we can set these
values directly in the DataSet schema (.xsd file) like the following:

<xs:element name="Address" type="xs:string" minOccurs="0"
msdata:ReadOnly="true" default="USA" />

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

I was a bit focussed on 'MaxLength' I guess, so I overlooked other
properties...
Thanks for the tip BUT I still can't find the 'MaxLength'-Value (together
with 'Type' the most important-one I need).

Regards,

Michael
 
Hi Michael,

To set the Maxlength in the dataset schema, you need to create your own
string type, for example:

xs:simpleType name="MyString">
<xs:restriction base="xs:string">
<xs:maxLength value="10" />
</xs:restriction>
</xs:simpleType>

The set the element to the customized type:

<xs:element name="name" type="mstns:MyString" minOccurs="0" />

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Luke,

Thanks for the tip.
If I understand this right "MaxLength" isn't available as a Property (in the
dataschema).
So then you define your own DataTypes.
This also implies that you have to create one datatype per
"MaxLength-Restriction"?

Maybe I'm missing the picture here, but how comes MaxLength can't be set in
the Schema? Is this a bug or if intentional: what's the idea behind this?

Kind regards,

Michael
 
Hi Michael,

What we know is this is by design. I'm not quite sure how this is designed
and cannot provide you with much help. Sorry.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top