Jump to content
Xtreme .Net Talk

FtKarras

Members
  • Posts

    3
  • Joined

  • Last visited

Personal Information

  • .NET Preferred Language
    C#

FtKarras's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Greattttttttt... I didn't know about any MySqlCommandBuilder... it works good Realy thank Machaira
  2. I think it is not possible. I am working on my laptop with local DB. There is no other access than mine. I have read in this forum that DBConcurrency raise when there is no row updated too. So I think my problem is at the bind of DataGrid column and table comumns making the UpdateComand parameters returns no row with the WHERE clause (bad @0 parameter???) but I have read my code one hundred times and can't find the problem.... I am NEW on dot net
  3. I can NOT update the table, have a DBConcurrency exception. The code I put is a form with a dataGrid filled with the table data of 'categorias' but when I leave the dataGrid to force a DGValidated I always obtain the same exception.... ... can anyone help me? public class clsFrmClientes : System.Windows.Forms.Form { private System.Windows.Forms.DataGrid dG; private MySqlDataAdapter myAdapter; private DataTable myData; public clsFrmClientes() { InitializeComponent(); myAdapter = new MySqlDataAdapter(); myData = new DataTable(); MySqlCommand selCommand = new MySqlCommand(); string selSQL; MySqlCommand updCommand = new MySqlCommand(); string updSQL; selSQL = "SELECT * FROM plq.categorias"; updSQL = "UPDATE plq.categorias SET categoria = @1, descripcion = @2 WHERE cod = @0"; try { // Select Command selCommand.Connection = clsGlobal.dbCon; selCommand.CommandText = selSQL; myAdapter.SelectCommand = selCommand; // Update Command updCommand.Connection = clsGlobal.dbCon; updCommand.CommandText = updSQL; MySqlParameter vParam1 = updCommand.Parameters.Add( "@1", MySqlDbType.VarChar, 1 ); vParam1.SourceColumn = "categoria"; vParam1.SourceVersion = DataRowVersion.Current; MySqlParameter vParam2 = updCommand.Parameters.Add( "@2", MySqlDbType.VarChar, 100 ); vParam2.SourceVersion = DataRowVersion.Current; vParam2.SourceColumn = "descripcion"; MySqlParameter vParam3 = updCommand.Parameters.Add( "@0", MySqlDbType.VarChar, 5 ); vParam3.SourceVersion = DataRowVersion.Original; vParam3.SourceColumn = "cod"; myAdapter.UpdateCommand = updCommand; myAdapter.Fill(myData); dG.DataSource = myData; } catch ( MySqlException ex ) { MessageBox.Show( "Hay un error leyendo de la base de datos: " + ex.Message ); } } [i] --> Here comes some Windows Forms Designer code and then... --> the InitializeComponent() code [/i] void DGValidated(object sender, System.EventArgs e) { try { myAdapter.Update( myData ); } catch (DBConcurrencyException ex) { MessageBox.Show( ex.Message ); } } } ... Thanks in advance
×
×
  • Create New...