Scimore Company Blog
Ramblings on databases

How to use BLOB data types with ScimoreDB

April 18, 2008 11:23 by scimore

The following sample code shows how to use BLOB data types with ScimoreDB.
The full source code of the sample project, which you can compile and execute, is located under http://www.scimore.com/download/2.5/BlobDemo.zip. The sample uses Scimore embedded database.

Suppose that we already have an established connection with a server.

ScimoreConnection connection;
ScimoreCommand command;

The code snippet showing how to insert an image into a BLOB field:

Bitmap image = SystemIcons.Warning.ToBitmap();
byte[] value = (byte[])TypeDescriptor.GetConverter(image).ConvertTo(image, typeof(byte[]));

command.CommandText = "INSERT INTO table_1 VALUES (@p1)";
ScimoreParameter p1 = new ScimoreParameter("p1", ScimoreDbType.Blob);
p1.Value = value;
command.Parameters.Add(p1);

int rowsAffected = command.ExecuteNonQuery();

And the following code snippet shows how to read data from a BLOB field

command.CommandText = "SELECT column_1 FROM table_1";
ScimoreDataReader reader = command.ExecuteReader();
while (reader.Read())
{
    value = (byte[])reader["column_1"];
    image = (Bitmap)TypeDescriptor.GetConverter(typeof(Bitmap)).ConvertFrom(value);
    image.Save("warning.bmp");
}


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , , , , ,
Categories:
Actions: E-mail | Permalink | Comments (7) | Comment RSSRSS comment feed

Related posts

Comments

April 18. 2008 12:49

radioman

saunu ;}

radioman

April 22. 2009 08:31

Dinesh

How many byte we can save in blob field of scimore database table

Dinesh

April 22. 2009 08:58

scimore

32.000 GB

scimore

April 25. 2009 12:26

Dinesh

But when i select the file more the 10 KB it dos not save.
Is there other to save more then 1o kb file
if any have code then please give please give tested code.

Dinesh

April 27. 2009 17:49

manish

I am also getting error, while saving file above 10 kb - help required ASAP

manish

April 28. 2009 07:18

scimore

What version of DB do you used?

Do you have an example?

Also, try 3.0 version, we have fixed many bugs since 2.5 there.

scimore

April 28. 2009 10:07

Dinesh

we are using scimoreDB 2.5
We have tested same sample but file size is bigger then 10 kb

As per documentation SCIMore 2.5 also supports 32 TB blob size

Dinesh

Comments are closed