Board index » delphi » Storing sets in database

Storing sets in database

Hi

How can I store/load a set in my database

type
   TUserOptions = (uoOption1, uoOption2, uoOption3, uoOption4, uoOption5);
   TUserOpSet = set of TUserOptions;

var
  Options : TUserOpSet;

Query.ParamByName('Options').AsInteger := ord(Options); // fails

regards
Henrik

 

Re:Storing sets in database


Try putting the set in a string as shown below then saving it in a
string field.

On Wed, 5 Jun 2002 12:01:20 +0200, "Henrik Nedergaard"

Quote
<hen...@hn-itservice.dk> wrote:
>Hi

>How can I store/load a set in my database

>type
>   TUserOptions = (uoOption1, uoOption2, uoOption3, uoOption4, uoOption5);
>   TUserOpSet = set of TUserOptions;

>var
>  Options : TUserOpSet;

  S:  String;
begin
  SetLength(S, SizeOf(Options);
  Move(Options, S[1], SizeOf(Options));

Quote

>Query.ParamByName('Options').AsInteger := ord(Options); // fails

>regards
>Henrik

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Re:Storing sets in database


Quote
>   Move(Options, S[1], SizeOf(Options));

Hi Bill

Thanks

I have solved the problem that way I just using the integer field and using
a move data from the set to an integer. Works like a charm.

regards
Henrik

Re:Storing sets in database


Try so:

Query.ParamByName('Options').AsInteger := Byte(Options);

--
With best regards, Mike Shkolnik
E-Mail: mshkol...@scalabium.com
WEB: http://www.scalabium.com

Henrik Nedergaard <hen...@hn-itservice.dk> D???
???Y??:3cfde14a$1_2@dnews...

Quote
> Hi

> How can I store/load a set in my database

> type
>    TUserOptions = (uoOption1, uoOption2, uoOption3, uoOption4, uoOption5);
>    TUserOpSet = set of TUserOptions;

> var
>   Options : TUserOpSet;

> Query.ParamByName('Options').AsInteger := ord(Options); // fails

> regards
> Henrik

Other Threads