Ver Mensaje Individual
  #3  
Antiguo 30-05-2011
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.077
Reputación: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Gracias
Ha salido un poco "descuadrado", pero creo que es esto:

Código:
string database = "test.fdb";

CreateEmbeddedDb(database, "test.sql");

FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
csb.ServerType = 1;
csb.Database = database;

using (FbConnection c = new FbConnection(csb.ToString()))
{
    c.Open();
            
    FbCommand cmdInsert = new FbCommand("INSERT INTO mytable(id, val) VALUES(@id, @val)", c);
    cmdInsert.Parameters.Add("@id", 1);
    cmdInsert.Parameters.Add("@val", new byte[] {1, 2, 3});
    cmdInsert.ExecuteNonQuery();

    FbCommand cmd = new FbCommand("SELECT val FROM mytable", c);
                
    using (FbDataReader r = cmd.ExecuteReader())
    {
        while (r.Read())
        {
            int size = 20;
            byte[] bytes = new byte[size];
            long count = r.GetBytes(0, 0, bytes, 0, size);
            for(int i = 0; i < count; i++)
                Console.WriteLine("Value: " + bytes[i]);
        }
    }
}
El caso es que dice esto:

Cita:
Because it is not possible to insert binary BLOB value in the SQL script we need to insert it in the code before reading.
El ejemplo, la verdad, es que no lo entiendo, y parece que no es lo que ando buscando.
Responder Con Cita