vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I have the following code (see below), very simple. It's a minimal example. The update command gives me: Concurrency violation: the UpdateCommand affected 0 of the expected 1 records. I also tried via ODBC, exactly same problem. What is wrong? How can I get it to work? Thank you, best regards, -Hendri. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { MySqlConnection mysqlCon = new MySqlConnection("server=localhost;user id=root;password=temp;database=cvz"); mysqlCon.Open(); MySqlDataAdapter mysqlDA = new MySqlDataAdapter("select * from job_1", mysqlCon); DataTable dataTable = new DataTable(); mysqlDA.Fill(dataTable); dataTable.Rows[0].BeginEdit(); dataTable.Rows[0]["E1"] = 0.9919919; dataTable.Rows[0].EndEdit(); MySqlCommandBuilder mysqlCB = new MySqlCommandBuilder(mysqlDA); mysqlDA.UpdateCommand = mysqlCB.GetUpdateCommand(); mysqlDA.Update(dataTable); } } } |
| ||||
| FYI, I found this. It's no solution, only a workaround in case you know what you're doing (and MySql .Net doesn't): http://forums.mysql.com/read.php?38,...7313#msg-67313 -> MySqlCommandBuilder mysqlCB = new MySqlCommandBuilder(mysqlDA); mysqlCB.ConflictOption = ConflictOption.OverwriteChanges; mysqlDA.UpdateCommand = mysqlCB.GetUpdateCommand(); mysqlDA.Update(dataTable); -Hendri. |
| Thread Tools | |
| Display Modes | |
|
|