Hi All,
I am facing an issue while commiting an updated dataset bound with my business object.
Form Description :
==================
My form has two Command Buttons[for server operation] named "AddRow" and "DeleteRow" for adding and deleting rows to the grid, respectively.
the business obeject named "bot_DemoTest1" for the grid is bound to a database table i.e., "tblTestTable"
Script for table :
===================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tblTestTable]
(
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[FirstColumn] [varchar](500) NULL,
[SecondColumn] [varchar](500) NULL,
[IsModified] [varchar](5) NULL,
CONSTRAINT [pk_Id] PRIMARY KEY CLUSTERED
(
[Id] ASC
)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[tblTestTable] ADD DEFAULT ((0)) FOR [IsModified]
GO
Problem Description :
=====================
when i add a new row(which was earlier not present in the database table) to the dataset of my business object and commit the form, then the row gets inserted to database table
without any problem, but problem arises when i add a new row(which was earlier not present in the database table) to the dataset and before commiting my form
i update one of it's columns i.e., "IsModified" = "1"; and then commit in that scenario it starts showing an error as : Exception "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records."
occurred when attempting to 'MBO update.
Steps followed :
================
Step_1 : Server side script(CodeActivity) written on "When button Pressed" event of "AddRow":
DataSet ds = this.Current.boDemoTest1.Read();
DataTable ordersTable = ds.Tables[0];
DataRow newRow = ds.Tables[0].NewRow();
newRow["FirstColumn"] = "John";
newRow["SecondColumn"] = "Methews";
newRow["IsModified"] = "0";
ds.Tables[0].Rows.Add(newRow);
this.Current.boDemoTest1.Write(ds);
Step_2 : Server side script(CodeActivity) written on "When button Pressed" event of "DeleteRow":
DataSet ds = this.Current.boDemoTest1.Read();
DataTable dt= ds.Tables[0];
DataRow rowToBeUpdated = ds.Tables[0].Rows[0];
rowToBeUpdated["IsModified"] = 1;
this.Current.boDemoTest1.Write(ds);