Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Inserting a zipfile into a BLOB column
Sun, Mar 16 2008 10:55 PMPermanent Link

"Prabha"
Hi ,

How would I store a zip file which has been read into a byte array, into a
BLOB column and retrieve it back ?
I'm using ElevateDB Unicode Server version 1.08.  I'm getting a conversion
error when I tried the following:

string cmdstring = "insert into zipped_data(Id, ,ZipContent) values(?,?)";

EDBCommand cmd = new EDBCommand(cmdStr, m_conn);

EDBParameter p1 = new EDBParameter();
p1.Value = 1; //first column has a hardcoded value of 1 for testing purposes

EDBParameter p2 = new EDBParameter();
p2.DbType = System.Data.DbType.Binary;
p2.ProviderType = EDBType.Blob;
p2.Value = data;          //data is a byte[] that contains the zip content.

cmd.Parameters.Add(p1);
cmd.Parameters.Add(p2);
cmd.Execute();

The conversion error is thrown for param 2.

Also how to query the BLOB data back? Should I use EDBReader.GetBytes() ?

thanks

Prabha

Tue, Mar 18 2008 11:29 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Prabha,

<< I'm using ElevateDB Unicode Server version 1.08.  I'm getting a
conversion error when I tried the following: >>

What is the exact error message that you're getting ?

Here is the code that you should use:

string cmdstring = "insert into zipped_data(Id, ,ZipContent)
values(:Id,:ZipContent)";

EDBCommand cmd = new EDBCommand(cmdStr, m_conn);

cmd.Parameters["Id"].Value = 1;
cmd.Parameters["ZipContent"].Value = data;
cmd.Execute();

ElevateDB, by default, has its EDBCommand.ParamCheck property set to True,
which means that it will parse and populate any parameters using the ":"
prefix and an actual parameter name.  That way you can simply refer to the
parameter by name, and not have to create the parameters or assign the
parameter data types.

<< Also how to query the BLOB data back? Should I use EDBReader.GetBytes() ?
>>

Yes, you can use GetBytes() or you can use GetValue().  Either one should
work.

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Mar 18 2008 12:38 PMPermanent Link

"Prabha"

Hi Tim,

  Thanks for your response.
  I have tried this before. And I tried it again today.
  I still keep getting this conversion error.

This is the exact error message.

"ElevateDB Error #1011 An error occurred with the parameter 2 (A conversion
error occurred)"

Here, Parameter 2 is the Blob Col in the database and

> cmd.Parameters["ZipContent"].Value = data;     // data here is a byte[]

-----------------------------------------------------------

1. If I convert this byte[] into a string and pass it to the parameter 2,
the error does not pop up.
I can see the exact no. of bytes stored in the database.

But, in this case when I read it, the zip file is corrupted and I'm unable
to unzip it.

(I'm using GetBytes and it seems to be working perfectly fine. It is just
the storing of the zip file into the Blob data.)

2. I tried uploading the zip file directly into the EDBManager and tried to
read that row thru my program.. It works perfectly fine

Prabha

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:0BA6AD5E-7B5E-49F9-9191-70A61F55B448@news.elevatesoft.com...
> Prabha,
>
> << I'm using ElevateDB Unicode Server version 1.08.  I'm getting a
> conversion error when I tried the following: >>
>
> What is the exact error message that you're getting ?
>
> Here is the code that you should use:
>
> string cmdstring = "insert into zipped_data(Id, ,ZipContent)
> values(:Id,:ZipContent)";
>
> EDBCommand cmd = new EDBCommand(cmdStr, m_conn);
>
> cmd.Parameters["Id"].Value = 1;
> cmd.Parameters["ZipContent"].Value = data;
> cmd.Execute();
>
> ElevateDB, by default, has its EDBCommand.ParamCheck property set to True,
> which means that it will parse and populate any parameters using the ":"
> prefix and an actual parameter name.  That way you can simply refer to the
> parameter by name, and not have to create the parameters or assign the
> parameter data types.
>
> << Also how to query the BLOB data back? Should I use EDBReader.GetBytes()
> ?
> >>
>
> Yes, you can use GetBytes() or you can use GetValue().  Either one should
> work.
>
> --
> Tim Young
> Elevate Software
> www.elevatesoft.com
>

Tue, Mar 18 2008 4:55 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Prabha,

<< Thanks for your response.
I have tried this before. And I tried it again today.
I still keep getting this conversion error. >>

Per my conversation with Carlton via email, I have found the problem and a
fix will be available by Thursday in a 1.09 release.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image