Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unable to stop concurrency violation
Message
From
30/04/2002 02:44:20
 
 
To
All
General information
Forum:
ASP.NET
Category:
Databases
Title:
Unable to stop concurrency violation
Miscellaneous
Thread ID:
00650760
Message ID:
00650760
Views:
61
Hi All,

Im having a bit of trouble handling a concurrency violation.

What im trying is:
SqlConnection sqlConnection1 = new SqlConnection();
SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter();
DataSet dataSet1 = new DataSet();

sqlConnection1.ConnectionString = "uid=;pwd=;initial catalog=\"Database\";data source=server;Connect Timeout=30";
sqlConnection1.Open();
while(sqlConnection1.State != ConnectionState.Open)
{

}
sqlDataAdapter1.SelectCommand = new SqlCommand(
	"select cforename, csurname, nperid from personnel", 
	sqlConnection1);

sqlDataAdapter1.Fill(dataSet1);

MessageBox.Show("Update your data then click ok.");

dataSet1.Tables[0].Rows[0]["cforename"] = "test";

SqlCommandBuilder sqlCB = new SqlCommandBuilder(sqlDataAdapter1);

try
{
	this.sqlDataAdapter1.Update(dataSet1);
}
catch(Exception Ex)
{
	DataSet CurrentData = new DataSet();

	sqlDataAdapter1.Fill(CurrentData);

	dataSet1.Merge(CurrentData, true);
	sqlDataAdapter1.Update(dataSet1);
}
On the second update in the catch, it causes a concurrency error despite what I thought was merging the current data in.

What it is actually doing is adding every record again into the dataset so it causes duplicates in the dataset and then still causes the concurrency error.

Can anyone show me what im doing wrong here??

Thanks,

Michael Henstock
AWS
A fish this fine deserves to be a fish nugget styled chunklet.
- Fry
Next
Reply
Map
View

Click here to load this message in the networking platform