| View previous topic :: View next topic |
| Author |
Message |
Jacob Havkrog Guest
|
Posted: Wed Jan 11, 2006 5:30 pm Post subject: How to write a set to a database |
|
|
Hi
What a conveniet way to write and write a value of type
TByteSet = Set of byte
to a database using ADO? The data type consists of 32 bytes. I'm not strong
in streams or blobs, a piece of code would be most appreciated. :-)
Thanks.
Jacob
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Wed Jan 11, 2006 9:33 pm Post subject: Re: How to write a set to a database |
|
|
var
bs: TByteSet;
....
- to write:
yourDataset.FieldByName(yourField).AsInteger := Integer(bs);
- to read:
bs := TByteSet(yourDataset.FieldByName(yourField).AsInteger);
--
With best regards, Mike Shkolnik
E-mail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
WEB: http://www.scalabium.com
"Jacob Havkrog" <a@a.a> wrote
| Quote: | Hi
What a conveniet way to write and write a value of type
TByteSet = Set of byte
to a database using ADO? The data type consists of 32 bytes. I'm not
strong
in streams or blobs, a piece of code would be most appreciated. :-)
Thanks.
Jacob
|
|
|
| Back to top |
|
 |
John Herbster Guest
|
Posted: Wed Jan 11, 2006 9:58 pm Post subject: Re: How to write a set to a database |
|
|
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote
| Quote: | TByteSet = Set of byte
var bs: TByteSet;
...
- to write:
yourDataset.FieldByName(yourField).AsInteger := Integer(bs);
- to read:
bs := TByteSet(yourDataset.FieldByName(yourField).AsInteger);
|
A byte is 0 .. 255. The SizeOf(TByteSet) will be 32 bytes,
so it is going to take something else, maybe like
yourDataset.FieldByName(yourField).SetData(@bs);
and
yourDataset.FieldByName(yourField).GetData(@bs);
where the size of the field is declared as SizeOf(TByteSet)
--JohnH
|
|
| Back to top |
|
 |
Jacob Havkrog Guest
|
Posted: Thu Jan 12, 2006 11:07 am Post subject: Re: How to write a set to a database |
|
|
Hi
"John Herbster" Wrote
| Quote: |
maybe like
yourDataset.FieldByName(yourField).SetData(@bs);
and
yourDataset.FieldByName(yourField).GetData(@bs);
where the size of the field is declared as SizeOf(TByteSet)
--JohnH
|
Now, if want to store a
var
bs: set of byte;
into an Access or SQL server table using your method, howdo I create the
field? Just like
ALTER TABLE MyTable ADD MyByteSet CHAR(32) ?
Also, is there a way in SQL queries to address the individual bits? Like
SELECT * FROM .. WHERE (1) IN MyByteSet
for selecting rows where the byte set contains the byte "1", or something
like that ? I guess not. The way do stuff like this is to make a separate
table for the elements of the byte set?
Thanks for your help
Jacob
|
|
| Back to top |
|
 |
|