473,513 Members | 2,399 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Data.DBConcurrencyException was unhandled

I am using Microsift Visual C# 2005 Express Edition and SQL Server 2005
Express Edition.
I have created a few tables in the IDE.

When I run my program in debug run the
dataAdapter.update(dataset.table), and the tables are empty, i get the
DBConcurrencyException (Message="Concurrency violation: the
UpdateCommand affected 0 of the expected 1 records.").

This only happends when the tables are empty. If I at designtime
populates the tables with one row each, this doesn't happend.

Any ideas on this?

Nov 15 '06 #1
3 5947
Put you update method here there more help you can get.

chanmm

"Cub71" <bj*****@gmail.comwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
>I am using Microsift Visual C# 2005 Express Edition and SQL Server 2005
Express Edition.
I have created a few tables in the IDE.

When I run my program in debug run the
dataAdapter.update(dataset.table), and the tables are empty, i get the
DBConcurrencyException (Message="Concurrency violation: the
UpdateCommand affected 0 of the expected 1 records.").

This only happends when the tables are empty. If I at designtime
populates the tables with one row each, this doesn't happend.

Any ideas on this?

Nov 16 '06 #2
The dataset is a typed dataset created with drag and drop in the IDE.
private void Form1_Load(object sender, EventArgs e)
{
daemployees = new SqlDataAdapter("SELECT * FROM employees",
connString);
SqlCommandBuilder cmdBldremployees = new
SqlCommandBuilder(daemployees);
daemployees.FillSchema(myCompanyDataSet1,
SchemaType.Source, "employees");
daemployees.Fill(myCompanyDataSet1, "employees");
}
private void createEmployees(int number)
{
for (int i = 1; i <= number; i++)
{
DataRow EmployeesRow =
myCompanyDataSet1.Employees.NewRow();
int newEmplNo = 37000 + totalnumberEmployees;
EmployeesRow["EmplNo"] = newEmplNo;
EmployeesRow["ReadyAt"] = "01.01.2006 0:00";

if (totalnumberEmployees < 3)
{
EmployeesRow["ReadyFrom"] = "LYR";
}
else if (totalnumberEmployees < 6)
{
EmployeesRow["ReadyFrom"] = "TOS";
}

else if (totalnumberEmployees < 8)
{
EmployeesRow["ReadyFrom"] = "ALF";
}

else if (totalnumberEmployees < 9)
{
EmployeesRow["ReadyFrom"] = "BDU";
}
else
{
EmployeesRow["ReadyFrom"] = "OSL";
}

totalnumberEmployees++;

myCompanyDataSet1.Employees.Rows.Add(EmployeesRow) ;

}

daEmployees.Update(myCompanyDataSet1.Employees); // This
is where it fails
updateLabels();
}

Nov 16 '06 #3
The only thing I can think of is reconfigure the dataset. You open the
Dataset then right click the buttom part then you should see something like
Configure Dataset or so.

chanmm

"Cub71" <bj*****@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
The dataset is a typed dataset created with drag and drop in the IDE.
private void Form1_Load(object sender, EventArgs e)
{
daemployees = new SqlDataAdapter("SELECT * FROM employees",
connString);
SqlCommandBuilder cmdBldremployees = new
SqlCommandBuilder(daemployees);
daemployees.FillSchema(myCompanyDataSet1,
SchemaType.Source, "employees");
daemployees.Fill(myCompanyDataSet1, "employees");
}
private void createEmployees(int number)
{
for (int i = 1; i <= number; i++)
{
DataRow EmployeesRow =
myCompanyDataSet1.Employees.NewRow();
int newEmplNo = 37000 + totalnumberEmployees;
EmployeesRow["EmplNo"] = newEmplNo;
EmployeesRow["ReadyAt"] = "01.01.2006 0:00";

if (totalnumberEmployees < 3)
{
EmployeesRow["ReadyFrom"] = "LYR";
}
else if (totalnumberEmployees < 6)
{
EmployeesRow["ReadyFrom"] = "TOS";
}

else if (totalnumberEmployees < 8)
{
EmployeesRow["ReadyFrom"] = "ALF";
}

else if (totalnumberEmployees < 9)
{
EmployeesRow["ReadyFrom"] = "BDU";
}
else
{
EmployeesRow["ReadyFrom"] = "OSL";
}

totalnumberEmployees++;

myCompanyDataSet1.Employees.Rows.Add(EmployeesRow) ;

}

daEmployees.Update(myCompanyDataSet1.Employees); // This
is where it fails
updateLabels();
}

Nov 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
536
by: Rafael | last post by:
Hi, I hope I can find some help for this problem IDE: Visual Studio.NET 2003 Developer Editio Language: C# Problem: "An unhandled exception of type 'System.NullReferenceException' occurred in...
0
9744
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
0
5264
by: silesius | last post by:
I've been using VS 2003 to develop a webapplication using C#. Today I exported the application to a remote webserver I begun experiencing problems. It's a simple application that retrieves some...
0
1168
by: Henrik de Jong | last post by:
Hello, I'm using radeditor. When I set the html-property to the text wich has to be altered, it gives me an error when try to save the new values of the html-proterty. It occurs only when i'm...
0
2741
by: silesius | last post by:
I've been using VS.NET 2003 to develop a webapplication using C#. Today I exported the application to another webserver I begun experiencing problems. It's a simple application that retrieves...
0
5622
by: NicK chlam via DotNetMonster.com | last post by:
this is the error i get System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. at System.Data.Common.DbDataAdapter.Update(DataRow dataRows, DataTableMapping tableMapping) at...
5
9629
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve...
1
1457
by: niju | last post by:
Hi all, I am using following code to update database; I am running two instances of the application and updating the same record. However, DBConcurrencyException doesn't fire. Is there something...
1
3147
by: Pedro Dinis | last post by:
i have this class library that connects to the database(see appconfig below) compiling 0 errors but when its running i amhaving this error An unhandled exception of type...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7545
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7111
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
5692
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,...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.