J
jorge
Hello all,
I'm coding with a typed dataset and adapters.
I cannot get the AutoIncrement to be updated to the dataset. Any help would
be gratelly appreciated.
Thanks
/ jorge
Check this out:
The TypedDataSet includes:
table1
---------------- 8< -----------------------
<xs:element name="PolicyID" msdata:AutoIncrement="true"
msdata:AutoIncrementStep="-1" msdata:AutoIncrementSeed="-1" type="xs:int" />
---------------- 8< -----------------------
table2
---------------- 8< -----------------------
<xs:element name="PolicyID" type="xs:int" />
---------------- 8< -----------------------
relations and contraints:
---------------- 8< -----------------------
<xs:unique name="PricePolicyDataSetKey1" msdatarimaryKey="true">
<xs:selector xpath=".//mstnsolicy" />
<xs:field xpath="mstnsolicyID" />
</xs:unique>
---------------- 8< -----------------------
<xs:keyref name="PolicyHasPeriods" refer="PricePolicyDataSetKey1">
<xs:selector xpath=".//mstnseriod" />
<xs:field xpath="mstnsolicyID" />
</xs:keyref>
---------------- 8< -----------------------
Code:
SqlDataAdapter adapter = new SqlDataAdapter("SELECT PolicyID, --- 8< ---
FROM pasPolicy", transaction.Connection);
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
builder.RefreshSchema();
adapter.SelectCommand.Transaction = transaction;
adapter.InsertCommand = builder.GetInsertCommand();
adapter.InsertCommand.CommandText += "; SELECT SCOPE_IDENTITY() AS
PolicyID";
adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.Both;
adapter.Update(policy.Policy);
policy.Policy.AcceptChanges();
I'm coding with a typed dataset and adapters.
I cannot get the AutoIncrement to be updated to the dataset. Any help would
be gratelly appreciated.
Thanks
/ jorge
Check this out:
The TypedDataSet includes:
table1
---------------- 8< -----------------------
<xs:element name="PolicyID" msdata:AutoIncrement="true"
msdata:AutoIncrementStep="-1" msdata:AutoIncrementSeed="-1" type="xs:int" />
---------------- 8< -----------------------
table2
---------------- 8< -----------------------
<xs:element name="PolicyID" type="xs:int" />
---------------- 8< -----------------------
relations and contraints:
---------------- 8< -----------------------
<xs:unique name="PricePolicyDataSetKey1" msdatarimaryKey="true">
<xs:selector xpath=".//mstnsolicy" />
<xs:field xpath="mstnsolicyID" />
</xs:unique>
---------------- 8< -----------------------
<xs:keyref name="PolicyHasPeriods" refer="PricePolicyDataSetKey1">
<xs:selector xpath=".//mstnseriod" />
<xs:field xpath="mstnsolicyID" />
</xs:keyref>
---------------- 8< -----------------------
Code:
SqlDataAdapter adapter = new SqlDataAdapter("SELECT PolicyID, --- 8< ---
FROM pasPolicy", transaction.Connection);
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
builder.RefreshSchema();
adapter.SelectCommand.Transaction = transaction;
adapter.InsertCommand = builder.GetInsertCommand();
adapter.InsertCommand.CommandText += "; SELECT SCOPE_IDENTITY() AS
PolicyID";
adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.Both;
adapter.Update(policy.Policy);
policy.Policy.AcceptChanges();