I do not understand why I get an error CS1586, specifically when I say new string[]
class ConsultaMySQL
{
private MySqlConnection conexion = new MySqlConnection("server=localhost; database=thepacioli; Uid=root; pwd=Valentin_01; Sslmode=none");
private DataSet ds;
private DataTable MostrarDatos()
{
conexion.Open();
MySqlCommand cmd = new MySqlCommand("select *from usuario", conexion);
MySqlDataAdapter ad = new MySqlDataAdapter(cmd);
ds = new DataSet();
ad.Fill(ds, "tabla");
conexion.Close();
return ds.Tables["tabla"];
}
private DataTable Buscar(string nombre)
{
conexion.Open();
MySqlCommand cmd = new MySqlCommand(string.Format("select *from usuario where nombre like '%(0)$'",nombre), conexion);
MySqlDataAdapter ad = new MySqlDataAdapter(cmd);
ds = new DataSet();
ad.Fill(ds, "tabla");
conexion.Close();
return ds.Tables["tabla"];
}
public bool Insertar(string id, string nombre, string segundo_nombre, string apellido, string sexo)
{
conexion.Open();
MySqlCommand cmd = new MySqlCommand(string.Format("Insert into usuario values (0), '(1)', '(2)', '(3)', '(4)'", new string[](id, nombre, segundo_nombre, apellido, sexo)), conexion);
int filasafectadas = cmd.ExecuteNonQuery();
conexion.Clone();
if (filasafectadas > 0) return true;
else return false;
}
public bool Eliminar(string id)
{
conexion.Open();
MySqlCommand cmd = new MySqlCommand(string.Format("delete from usuario where id={0}", id), conexion);
int filasafectadas = cmd.ExecuteNonQuery();
conexion.Clone();
if (filasafectadas > 0) return true;
else return false;
}
public bool Actualizar(string id, string nombre, string segundo_nombre, string apellido, string sexo)
{
conexion.Open();
MySqlCommand cmd = new MySqlCommand(string.Format("update usuario set nombre={0}, segundo_nombre={1}, apellido={2}, sexo={3} where id={4}", new string[] (nombre, segundo_nombre, apellido, sexo, id)), conexion);
int filasafectadas = cmd.ExecuteNonQuery();
conexion.Clone();
if (filasafectadas > 0) return true;
else return false;
}
}