BLOBs
Posted: Fri 29 Sep 2006 10:41
Hi.
There's a couple of things I'd like to clarify using BLOBs.
The native C API has a function available. This creates a new LO and returns its OID, which is then used in subsequent calls to the lo_(...) functions.
I have a table defined as:
The process I'm use to working with is create a new BLOB, add its OID to the tb_Variable_Map table, and then when required, pull its OID from there to manipulate the BLOB.
The following is an example from the documentation.
I've tried this and get
I get a feeling I may need to re-think my approach to this using the Framework. Is there a tutorial/sample code available which has the complete stages of take empty database, create table to store blob data, insert some rows and blob data, select some rows and write some data?
Cheers,
Jon.
There's a couple of things I'd like to clarify using BLOBs.
The native C API has a
Code: Select all
Oid lo_creat(PGconn* conn, int mode)
I have a table defined as:
Code: Select all
create table tb_variable_map (
id serial primary key,
varname text,
varclass text,
last_modification timestamp,
external_data oid
);
The following is an example from the documentation.
Code: Select all
public void UploadBlob(PgSqlConnection pgConnection)
{
FileStream fs = new FileStream("D:\Tmp\_Water.bmp", FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
PgSqlBlob myBlob = new PgSqlBlob(r.ReadBytes((int)fs.Length));
PgSqlCommand pgCommand = new PgSqlCommand("INSERT INTO Test.Pictures (ID, PicName, Picture) VALUES(1,'Water',:Pictures)", pgConnection);
pgCommand.Parameters.Add("Pictures",myBlob);
pgConnection.Open();
try
{
Console.WriteLine(pgCommand.ExecuteNonQuery()+" rows affected.");
}
finally
{
pgConnection.Close();
r.Close();
}
}
.Unable to cast object of type 'CoreLab.PostgreSql.PgSqlBlob' to type 'System.IConvertible'
I get a feeling I may need to re-think my approach to this using the Framework. Is there a tutorial/sample code available which has the complete stages of take empty database, create table to store blob data, insert some rows and blob data, select some rows and write some data?
Cheers,
Jon.