Ver Mensaje Individual
  #3  
Antiguo 30-05-2011
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is offline
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.669
Reputación: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví 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