BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to write a set to a database

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Jacob Havkrog
Guest





PostPosted: Wed Jan 11, 2006 5:30 pm    Post subject: How to write a set to a database Reply with 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
Mike Shkolnik
Guest





PostPosted: Wed Jan 11, 2006 9:33 pm    Post subject: Re: How to write a set to a database Reply with quote



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





PostPosted: Wed Jan 11, 2006 9:58 pm    Post subject: Re: How to write a set to a database Reply with quote




"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





PostPosted: Thu Jan 12, 2006 11:07 am    Post subject: Re: How to write a set to a database Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.