how to set seed & increment in xsd file

  • Thread starter Thread starter Scott Emick
  • Start date Start date
S

Scott Emick

I remember the way I dealt with identity fields in my datasets that were a
updating sql 2000 table with an identity field was to set (I think)
autoincrement, and seed/increment to -1 and it worked fine. I cannot find
the documentation on the proper syntax of how to do this now though, I am
scouring MSDN, newsgroups and the internet...

Anyone know how? Below is what I have now, and it doesn't work - the
sqldataadapter tries to update field "ID" despite it being readonly...

Thanks,

Scott Emick

<?xml version="1.0" encoding="utf-8" ?>

<xs:schema id="receipt" targetNamespace="http://tempuri.org/receipt.xsd"
elementFormDefault="qualified"

attributeFormDefault="qualified" xmlns="http://tempuri.org/receipt.xsd"
xmlns:mstns="http://tempuri.org/receipt.xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">

<xs:element name="receipt" msdata:IsDataSet="true">

<xs:complexType>

<xs:choice maxOccurs="unbounded">

<xs:element name="keycodereceipt">

<xs:complexType>

<xs:sequence>

<xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true"
type="xs:int" />

<xs:element name="orderId" type="xs:string" minOccurs="0" />

<xs:element name="rev" type="xs:decimal" minOccurs="0" />

<xs:element name="keycode" type="xs:string" minOccurs="0" />

<xs:element name="Date" type="xs:dateTime" />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:choice>

</xs:complexType>

<xs:unique name="receiptKey1" msdata:PrimaryKey="true">

<xs:selector xpath=".//mstns:keycodereceipt" />

<xs:field xpath="mstns:Id" />

</xs:unique>

</xs:element>

</xs:schema>
 
I just found my own answer,

it goes like this: (or you can click the fieldname in the designer and the
properties button on the top toolbar and set it)

Scott

<xs:element name="Id" msdata:ReadOnly="true" msdata:AutoIncrement="true"
type="xs:int" msdata:AutoIncrementSeed="-1"

msdata:AutoIncrementStep="-1" />
 
Back
Top