473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

error when inserting into table having instead of trigger from entity data framework

Hi All,

I am using EF 4,There is a instead of trigger in the table Service.
The trigger get the value of the serviceTypeid and if the
serviceTypeid is not present in the master table the trigger insert the record in the master table.

Now when i am going to save the records in the Service,

i am getting the error that "Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries."

I googled the issue and found one solution which i used,
the code is something like
Expand|Select|Wrap|Line Numbers
  1. foreach (Services obService in _lstService)
  2.                 {
  3.                     entities.Services.AddObject(obService);
  4.                 }
  5.                 try
  6.                 {
  7.  
  8.                     entities.SaveChanges();
  9.                 }
  10.                 catch (OptimisticConcurrencyException ex)
  11.                 {
  12.                     entities.Refresh(RefreshMode.ClientWins, entities.Services);
  13.                     entities.SaveChanges();
  14.                 }
but it doen't solve my problem and getting the same error.

Please help me out to fix this issue
Feb 8 '12 #1

✓ answered by PsychoCoder

Check out the selected answer, I think it may help you with this issue.

1 5602
PsychoCoder
465 Expert Mod 256MB
Check out the selected answer, I think it may help you with this issue.
Feb 9 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: pmud | last post by:
I have an ASP.NET web application using C# code. I am trying to insert values from a web form into an SQL database. I am using SQL COMMAND object for this. I need to know HOW TO INSERT THE RADIO...
2
by: Rasta | last post by:
Hi, I've created a new table in a SQL Server db called 'LGBProdDetails' and I keep getting an error from my asp page that queries the table The error is: Category=Microsoft OLE DB Provider for...
2
by: aaronk321 | last post by:
Look below.. I'm baffled - what is going on? db2 => select tablespace_name from table(snapshot_tbs('epmdev01', -1)) as snapshot_tbs Do you want to execute the above command ? (y/n) y ...
1
by: Muhammad Usman | last post by:
hi, I have a table of student which contain four fields that are id(primary key number) , name(text),semester(text)and corse(text), When I insert values in a student table.Explorer Show the...
4
by: Sanjeev K B | last post by:
Hi all, I am working on a project involving Datagrid with an extended feature of combo box i am trying to stop the occurance of duplicate ID's i want to trap the message "Error when...
1
by: suslikovich | last post by:
Hi all, I am getting this error when insert values from one table to another in the first table the values are varchar (10). In the second they are datetime. The format of the data is mm/dd/yyyy...
4
by: Nikki | last post by:
When executing my insert statement, I am receiving the error message 'string literal too long'. The field is an xml datatype and I am inserting the xml as a string. Do I need to convert it to a...
4
by: cutequencher | last post by:
i am having this error when i am about to delete a data row inline with this is a message box saying: object reference not set to an instance of an object. do you want to correct the value? if...
2
ak1dnar
by: ak1dnar | last post by:
Hi, I am getting some sql errors when trying to insert a record to mysql table using asp.net application. Let me explain the scenario for your reference. This asp.net web form is executing...
13
by: smiler2505 | last post by:
Sub cmbEnt_NotInList(NewData As String, Response As Integer) Answer = MsgBox("add?", vbYesNo, "add?") If Answer = vbYes Then DoCmd.Close acForm, "frmOrd" ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.