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.