472,145 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

How to store integer-array in SQL-Database in a BLOB ( Binary large object )

I want store an integer-array of 1000 Values in a blob in a SQL-database.

I will do this every 10 Seconds.

How can I do this ????

What datatypes a have to use ???
Thanks
for any help
Peter
Nov 20 '05 #1
10 5059
The best way is to use an image type in your database (gives you 2gb of
datastorage).

After that.. use a BinaryFormatter to serialize the array to binary
saveable format...

Insert into blob...

why you wnat to use a blob confuses me, but to each his own...
"Peter Stojkovic" <Pe*************@gmx.net> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
I want store an integer-array of 1000 Values in a blob in a SQL-database.

I will do this every 10 Seconds.

How can I do this ????

What datatypes a have to use ???
Thanks
for any help
Peter

Nov 20 '05 #2
CJ,
If its always an Integer array. I would consider using System.Buffer to
block copy the integer array to & from an array of Bytes.

Of course the BinaryFormatter is more flexible.

Hope this helps
Jay

"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:uJ**************@TK2MSFTNGP12.phx.gbl...
The best way is to use an image type in your database (gives you 2gb of
datastorage).

After that.. use a BinaryFormatter to serialize the array to binary
saveable format...

Insert into blob...

why you wnat to use a blob confuses me, but to each his own...
"Peter Stojkovic" <Pe*************@gmx.net> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
I want store an integer-array of 1000 Values in a blob in a SQL-database.
I will do this every 10 Seconds.

How can I do this ????

What datatypes a have to use ???
Thanks
for any help
Peter


Nov 20 '05 #3
Hey Jay,

Didn't know about that one. I was just going with the fastest/least
confusing way I could think of doing it with. =)

I have no idea why they want to do it, but I'm *assuming* (beware!) its
because he wants to maintain persistance in some way..

then again, I could be wrong.

-CJ

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ue****************@tk2msftngp13.phx.gbl...
CJ,
If its always an Integer array. I would consider using System.Buffer to
block copy the integer array to & from an array of Bytes.

Of course the BinaryFormatter is more flexible.

Hope this helps
Jay

"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:uJ**************@TK2MSFTNGP12.phx.gbl...
The best way is to use an image type in your database (gives you 2gb of
datastorage).

After that.. use a BinaryFormatter to serialize the array to binary
saveable format...

Insert into blob...

why you wnat to use a blob confuses me, but to each his own...
"Peter Stojkovic" <Pe*************@gmx.net> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
I want store an integer-array of 1000 Values in a blob in a SQL-database.
I will do this every 10 Seconds.

How can I do this ????

What datatypes a have to use ???
Thanks
for any help
Peter



Nov 20 '05 #4
CJ,
I'm not sure what Peter's intent is either, I'm sure (hope at least) they
thought of the ramifications of storing arrays of integers in database
fields... I would have probably normalized the data into a child table...

Jay
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Hey Jay,

Didn't know about that one. I was just going with the fastest/least
confusing way I could think of doing it with. =)

I have no idea why they want to do it, but I'm *assuming* (beware!) its
because he wants to maintain persistance in some way..

then again, I could be wrong.

-CJ

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ue****************@tk2msftngp13.phx.gbl...
CJ,
If its always an Integer array. I would consider using System.Buffer to
block copy the integer array to & from an array of Bytes.

Of course the BinaryFormatter is more flexible.

Hope this helps
Jay

"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:uJ**************@TK2MSFTNGP12.phx.gbl...
The best way is to use an image type in your database (gives you 2gb of datastorage).

After that.. use a BinaryFormatter to serialize the array to binary
saveable format...

Insert into blob...

why you wnat to use a blob confuses me, but to each his own...
"Peter Stojkovic" <Pe*************@gmx.net> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
> I want store an integer-array of 1000 Values in a blob in a

SQL-database.
>
> I will do this every 10 Seconds.
>
> How can I do this ????
>
> What datatypes a have to use ???
>
>
> Thanks
> for any help
> Peter
>
>



Nov 20 '05 #5
Hi Jay,

I was so sure that you would give the answer on

Dim aByte() as Byte
aByte = myIntegerArray.EncodedByJay

That I did not, because it is something I always have to search for and have
the idea that you know it direct.

The rest would be peanuts (Can work fine in my opinion).

(When you have no direct answer than tell it, it is not that I am to lazy
for it)
Cor
Nov 20 '05 #6
As I understood, you would prefere a Image-type ,

I dont know what is a "image" type

I am using SQL-AnyWhere From SYBASE 9.01

There is no image-type available for a column

Peter
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:uJ**************@TK2MSFTNGP12.phx.gbl...
The best way is to use an image type in your database (gives you 2gb of
datastorage).

After that.. use a BinaryFormatter to serialize the array to binary
saveable format...

Insert into blob...

why you wnat to use a blob confuses me, but to each his own...
"Peter Stojkovic" <Pe*************@gmx.net> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
I want store an integer-array of 1000 Values in a blob in a SQL-database.
I will do this every 10 Seconds.

How can I do this ????

What datatypes a have to use ???
Thanks
for any help
Peter


Nov 20 '05 #7
Peter,
An "image" type is a blob. For what ever SQl-AnyWhere's "blob" type is, you
can use the technique identified by CJ or I.

Hope this helps
Jay

"Peter Stojkovic" <Pe*************@gmx.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
As I understood, you would prefere a Image-type ,

I dont know what is a "image" type

I am using SQL-AnyWhere From SYBASE 9.01

There is no image-type available for a column

Peter
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:uJ**************@TK2MSFTNGP12.phx.gbl...
The best way is to use an image type in your database (gives you 2gb of
datastorage).

After that.. use a BinaryFormatter to serialize the array to binary
saveable format...

Insert into blob...

why you wnat to use a blob confuses me, but to each his own...
"Peter Stojkovic" <Pe*************@gmx.net> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
I want store an integer-array of 1000 Values in a blob in a SQL-database.
I will do this every 10 Seconds.

How can I do this ????

What datatypes a have to use ???
Thanks
for any help
Peter



Nov 20 '05 #8
Further note...

Image type is a 16 byte pointer to a 2 gig max data segment in the database.
The varBinary field only allows a max of 8000 bytes I believe.

which sucks except for passwords.

=)

"Peter Stojkovic" <Pe*************@gmx.net> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
As I understood, you would prefere a Image-type ,

I dont know what is a "image" type

I am using SQL-AnyWhere From SYBASE 9.01

There is no image-type available for a column

Peter
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:uJ**************@TK2MSFTNGP12.phx.gbl...
The best way is to use an image type in your database (gives you 2gb of
datastorage).

After that.. use a BinaryFormatter to serialize the array to binary
saveable format...

Insert into blob...

why you wnat to use a blob confuses me, but to each his own...
"Peter Stojkovic" <Pe*************@gmx.net> wrote in message
news:e0**************@TK2MSFTNGP09.phx.gbl...
I want store an integer-array of 1000 Values in a blob in a SQL-database.
I will do this every 10 Seconds.

How can I do this ????

What datatypes a have to use ???
Thanks
for any help
Peter



Nov 20 '05 #9
Cor,
Why would I give a "bogus" answer? :-) Or is myIntegerArray a class that has
a EncodedByJay method on it?

The OP wants to put an integer array into a database, the two "better"
methods of doing this is binary serialization or System.Buffer.BlockCopy.
The third "better" method would be XML serialization. IMHO any other method
would be "more" work, hence not as "better", however these other methods may
be more what the OP needs, for example, the OP could use a loop & a string
builder to convert the array into a comma separated string, then store the
string in the database. To get the array out, he could use String.Split &
Integer.Parse in a loop...

I don't really see where Encoding would apply in this question per se. As
encoding usually entails changing from one format to another, such as
Unicode to ASCII. I don't really see that the OP wants to change the format
of the integers such as from Unicode to ASCII... (unless you meant integer
array to String & back, then I'm following you).

If you had an idea of how the OP could "encode" the integer array to be
stored, by all means give it.

Hope this helps
Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:e1**************@TK2MSFTNGP12.phx.gbl...
Hi Jay,

I was so sure that you would give the answer on

Dim aByte() as Byte
aByte = myIntegerArray.EncodedByJay

That I did not, because it is something I always have to search for and have the idea that you know it direct.

The rest would be peanuts (Can work fine in my opinion).

(When you have no direct answer than tell it, it is not that I am to lazy
for it)
Cor

Nov 20 '05 #10
Hi Jay,
Why would I give a "bogus" answer? :-) Or is myIntegerArray a class that has a EncodedByJay method on it?


I was a fool, I do not know why however in this thread I was thinking that
an integer was a byte, I hope that you understand that I know that it is
not.

Than because of your challenge I tried doing it. However I give up, the
result would have all in it I hate, unreadable trash made because it was a
challenge.

I could of course have serialized the integer array and than made from that
a blob, however that was something that was not my intention. I would have
made a bytearray of couples of 4 bytes.

:-)

Cor
Nov 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by jose luis fernandez diaz | last post: by
1 post views Thread by Paul W | last post: by
4 posts views Thread by Jon | last post: by
7 posts views Thread by thisismyidentity | last post: by
8 posts views Thread by Candace | last post: by
33 posts views Thread by Prasad | last post: by
7 posts views Thread by laura | last post: by
39 posts views Thread by rembremading | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.