
12/08/2011, 08:09
|
| | Fecha de Ingreso: enero-2008
Mensajes: 229
Antigüedad: 17 años, 1 mes Puntos: 0 | |
Respuesta: DataAdapter que recupere id al hacer insert public void UpdateMySqlWithDataTable(string conn, DataTable table)
{
try
{
SqlConnect myConn = new SqlConnect(conn);
MySqlConnection _myConn = myConn.ConnectToMySQL(conn);
MySqlDataAdapter da = new MySqlDataAdapter("select * from tbl_cr_control_report", _myConn);
DataSet ds = new DataSet();
ds.Tables.Add(table);
da.Fill(ds,"Test"); da.AcceptChangesDuringFill = true; //No funciona
MySqlCommandBuilder cmd = new MySqlCommandBuilder(da);
da.UpdateCommand = cmd.GetUpdateCommand();
da.InsertCommand = cmd.GetInsertCommand();
_myConn.Open();
da.Update(ds, "Test");
_myConn.Close();
}
catch (Exception e)
{
throw new Exception(e.Message);
}
finally
{
} |