El lun, 25-08-2003 a las 20:01, Sergio Blanco Cuaresma escribi�: > I have attached some code that fails, it does a consult to a MySQL using > DataSets and adds a new Row to that DataSet. It fails when it tries to > update the Data Base:
Ups! I forgot the attach! Sorry! -- [aka Marble] Registered LiNUX user #140941 <> http://counter.li.org/ Socio #3274 de HispaLinux <> http://www.hispalinux.es Miembro de GPL URV <> http://www.gplurv.org GnuPG key: 0x0ED2CF9D <> pgp.escomposlinux.org
using System;
using System.Data;
using ByteFX.Data.MySQLClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=localhost;" +
"Database=monotest;" +
"User ID=mono;" +
"Password=XXXXX;";
/* personas is a table with 2 string columns: firstname, lastname*/
MySQLConnection conn = new MySQLConnection(connectionString);
MySQLDataAdapter da = new MySQLDataAdapter("select * from personas", conn);
DataSet ds = new DataSet();
da.Fill(ds, "personas");
DataTable dt = ds.Tables["personas"];
//CREATE A NEW ROW
DataRow nuevaFila = dt.NewRow();
nuevaFila["firstname"] = "Pepe";
nuevaFila["lastname"] = "Salvador";
dt.Rows.Add(nuevaFila);
// now perform the update
MySQLCommandBuilder cb = new MySQLCommandBuilder(da);
da.Update(ds, "personas");
}
}
signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmadadigitalmente
