TableAdapter.Update() problem.
-
hi in my solution, i created a table adapter and set select,insert,update,delete actions to my own stored procedures, then for add row, write the following code :
FrmCategory frm = new FrmCategory(false, false);
DsStack.CategoriesRow newRow = this.dt.NewCategoriesRow();
Session.SaveInSession("newCategory", newRow);
if (frm.ShowDialog() == DialogResult.OK)
{
newRow = Session.LoadFromSession("newCategory") as DsStack.CategoriesRow;
this.dt.Rows.Add(newRow);
this.adapter.Update(this.dt); // error occured in this line
}When my table in database is empty : the first row add to table successfully, but the second row has not been add to database and the following error has shown me :
**Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.**
where does my problem and how to solve it ? thanks -
hi in my solution, i created a table adapter and set select,insert,update,delete actions to my own stored procedures, then for add row, write the following code :
FrmCategory frm = new FrmCategory(false, false);
DsStack.CategoriesRow newRow = this.dt.NewCategoriesRow();
Session.SaveInSession("newCategory", newRow);
if (frm.ShowDialog() == DialogResult.OK)
{
newRow = Session.LoadFromSession("newCategory") as DsStack.CategoriesRow;
this.dt.Rows.Add(newRow);
this.adapter.Update(this.dt); // error occured in this line
}When my table in database is empty : the first row add to table successfully, but the second row has not been add to database and the following error has shown me :
**Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.**
where does my problem and how to solve it ? thanks -
hi in my solution, i created a table adapter and set select,insert,update,delete actions to my own stored procedures, then for add row, write the following code :
FrmCategory frm = new FrmCategory(false, false);
DsStack.CategoriesRow newRow = this.dt.NewCategoriesRow();
Session.SaveInSession("newCategory", newRow);
if (frm.ShowDialog() == DialogResult.OK)
{
newRow = Session.LoadFromSession("newCategory") as DsStack.CategoriesRow;
this.dt.Rows.Add(newRow);
this.adapter.Update(this.dt); // error occured in this line
}When my table in database is empty : the first row add to table successfully, but the second row has not been add to database and the following error has shown me :
**Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.**
where does my problem and how to solve it ? thanksYour Update method waiting for 1 record to be updated, but your update sp doesn't update any row. Check you sp manually, sent the same values by parameter and watch the results.
-
Your Update method waiting for 1 record to be updated, but your update sp doesn't update any row. Check you sp manually, sent the same values by parameter and watch the results.
thanks for replies my sp code is :
Create Procedure [dbo].[sp_Categories_Insert]
@categoryName nvarchar(30),
@description nvarchar(400)
As
Begin
Insert Into Categories
([categoryName],[description])
Values
(@categoryName,@description)Declare @ReferenceID int Select @ReferenceID = @@IDENTITY Return @ReferenceID
End
do i change sp code ?
-
thanks for replies my sp code is :
Create Procedure [dbo].[sp_Categories_Insert]
@categoryName nvarchar(30),
@description nvarchar(400)
As
Begin
Insert Into Categories
([categoryName],[description])
Values
(@categoryName,@description)Declare @ReferenceID int Select @ReferenceID = @@IDENTITY Return @ReferenceID
End
do i change sp code ?
When You run this proc, what the value of @ReferenceID?
-
When You run this proc, what the value of @ReferenceID?