Código:
y me dicemisqlDa.Update(miDt, clientes.DataMember);
No se controló InvalidOperationException:
When MySqlCommandBuilder.ReturnGeneratedIdentifiers is true, MySqlCommand.UpdatedRowSource must be set to None.
a que se debe?
dejo el codigo completo:
Código:
se agradecen las respuestas! 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; using System.Data.SqlClient; namespace Milo_soft { public partial class Form1 : Form { MySqlConnection Conexion = new MySqlConnection(); MySqlDataAdapter misqlDa = new MySqlDataAdapter(); DataSet miDt = new DataSet(); BindingSource clientes = new BindingSource(); String cadena; MySqlCommandBuilder cmdbuild = new MySqlCommandBuilder(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { try { cadena = "Server=localhost;User id=root; password=;Database=milo;"; Conexion.ConnectionString = cadena; Conexion.Open(); } catch (MySqlException ex) { MessageBox.Show("Error "+ Convert.ToString(ex)); } string consulta = "SELECT * From clientes"; misqlDa = new MySqlDataAdapter(consulta, Conexion); misqlDa.Fill(miDt, "clientes"); clientes.DataSource = miDt; clientes.DataMember = "clientes"; bindingNavigator1.BindingSource = clientes; dataGridView1.DataSource = clientes; } private void button1_Click(object sender, EventArgs e) { cmdbuild = new MySqlCommandBuilder(this.misqlDa); misqlDa.InsertCommand = cmdbuild.GetInsertCommand(); misqlDa.DeleteCommand = cmdbuild.GetDeleteCommand(); misqlDa.UpdateCommand = cmdbuild.GetUpdateCommand(); //misqlDa.Update(miDt, dataGridView1); misqlDa.Update(miDt, clientes.DataMember); //anda solo hasta 3 misqlDa.Update(miDt.Tables["clientes"]); } private void guardar_Click(object sender, EventArgs e) { } } }