By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,030 Members | 2,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,030 IT Pros & Developers. It's quick & easy.

Using bitwise to create a multiple selection listbox and having it bound to a sql

P: n/a
I'm trying to figure out a way to list several items in a listbox and let
the user select any number of items in the listbox. I have tried to code in
the items as bitwise items but all it stores in the database is the top item
in the listbox.

How can I get the listbox to add all the bit values to be stored and also
come out properly when viewed later?
Example:

SQL Table = Valid Phases Lookup
Name Bitwise
Phase-10 1
Phase-20 2
Phase-30 4
Phase-40 8
Phase-60 16
Phase-70 32
SQL Table = Projects
Name Stored Type
ProjectName nvarchar
ValidPhases bigint (using listbox in c# with values
bound to lookup table above)
....Otherstuff...
Other notes:
I do have "MultiExtended" as the Selection Mode.
ValueMode to use the bitwise value.

Just having trouble getting the bitwise values to add up in the program and
send the correct value to the database.

Ive attempted a custom listbox and combo-box. Please help.

Jay
Nov 14 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rad
On Tue, 14 Nov 2006 11:54:52 -0500, "Jay Ruyle"
<ja*****@rdjarchitects.comwrote:
>I'm trying to figure out a way to list several items in a listbox and let
the user select any number of items in the listbox. I have tried to code in
the items as bitwise items but all it stores in the database is the top item
in the listbox.

How can I get the listbox to add all the bit values to be stored and also
come out properly when viewed later?
Example:

SQL Table = Valid Phases Lookup
Name Bitwise
Phase-10 1
Phase-20 2
Phase-30 4
Phase-40 8
Phase-60 16
Phase-70 32
SQL Table = Projects
Name Stored Type
ProjectName nvarchar
ValidPhases bigint (using listbox in c# with values
bound to lookup table above)
...Otherstuff...
Other notes:
I do have "MultiExtended" as the Selection Mode.
ValueMode to use the bitwise value.

Just having trouble getting the bitwise values to add up in the program and
send the correct value to the database.

Ive attempted a custom listbox and combo-box. Please help.

Jay
There's a difference between the storage of datetime values in the
..NET framework and SQL Server. Read these articles for some details of
the difference and some possible workarous:

http://www.velocityreviews.com/forum...e-problem.html

http://www.eggheadcafe.com/articles/20021111.asp

http://blogs.wdevs.com/angelos/archi...6/02/3660.aspx
Nov 14 '06 #2

P: n/a
Rad
On Wed, 15 Nov 2006 00:24:38 +0300, Rad <no****@nospam.comwrote:
>On Tue, 14 Nov 2006 11:54:52 -0500, "Jay Ruyle"
<ja*****@rdjarchitects.comwrote:
>>I'm trying to figure out a way to list several items in a listbox and let
the user select any number of items in the listbox. I have tried to code in
the items as bitwise items but all it stores in the database is the top item
in the listbox.

How can I get the listbox to add all the bit values to be stored and also
come out properly when viewed later?
Example:

SQL Table = Valid Phases Lookup
Name Bitwise
Phase-10 1
Phase-20 2
Phase-30 4
Phase-40 8
Phase-60 16
Phase-70 32
SQL Table = Projects
Name Stored Type
ProjectName nvarchar
ValidPhases bigint (using listbox in c# with values
bound to lookup table above)
...Otherstuff...
Other notes:
I do have "MultiExtended" as the Selection Mode.
ValueMode to use the bitwise value.

Just having trouble getting the bitwise values to add up in the program and
send the correct value to the database.

Ive attempted a custom listbox and combo-box. Please help.

Jay

There's a difference between the storage of datetime values in the
.NET framework and SQL Server. Read these articles for some details of
the difference and some possible workarous:

http://www.velocityreviews.com/forum...e-problem.html

http://www.eggheadcafe.com/articles/20021111.asp

http://blogs.wdevs.com/angelos/archi...6/02/3660.aspx
Sorry, mixed up my Agent windows :(

But since I am here anyway, I might as well chip in.

First of all, If I understand your architecture. If someone selects
Phase 10 and Phase 20, I am you store 3 in the database.

If this is the case I'm not sure you can databind directly.

You might have to loop through your listbox items to manually select
the valid phases.

Random question ... How do you handle queries with this design? How
can I retrieve all items at Phase 10 and Phase 20?
Nov 14 '06 #3

P: n/a

"Rad" <no****@nospam.comwrote in message
news:4o********************************@4ax.com...
On Wed, 15 Nov 2006 00:24:38 +0300, Rad <no****@nospam.comwrote:
>>On Tue, 14 Nov 2006 11:54:52 -0500, "Jay Ruyle"
<ja*****@rdjarchitects.comwrote:
>>>I'm trying to figure out a way to list several items in a listbox and let
the user select any number of items in the listbox. I have tried to code
in
the items as bitwise items but all it stores in the database is the top
item
in the listbox.

How can I get the listbox to add all the bit values to be stored and also
come out properly when viewed later?
Example:

SQL Table = Valid Phases Lookup
Name Bitwise
Phase-10 1
Phase-20 2
Phase-30 4
Phase-40 8
Phase-60 16
Phase-70 32
SQL Table = Projects
Name Stored Type
ProjectName nvarchar
ValidPhases bigint (using listbox in c# with values
bound to lookup table above)
...Otherstuff...
Other notes:
I do have "MultiExtended" as the Selection Mode.
ValueMode to use the bitwise value.

Just having trouble getting the bitwise values to add up in the program
and
send the correct value to the database.

Ive attempted a custom listbox and combo-box. Please help.

Jay

There's a difference between the storage of datetime values in the
.NET framework and SQL Server. Read these articles for some details of
the difference and some possible workarous:

http://www.velocityreviews.com/forum...e-problem.html

http://www.eggheadcafe.com/articles/20021111.asp

http://blogs.wdevs.com/angelos/archi...6/02/3660.aspx

Sorry, mixed up my Agent windows :(

But since I am here anyway, I might as well chip in.

First of all, If I understand your architecture. If someone selects
Phase 10 and Phase 20, I am you store 3 in the database.

If this is the case I'm not sure you can databind directly.

You might have to loop through your listbox items to manually select
the valid phases.

Random question ... How do you handle queries with this design? How
can I retrieve all items at Phase 10 and Phase 20?
Correct you would store 3 in the database.

I did make it unbound , but when I grab the value from the listbox it
returns the value of the top item and not a collection of items or tally of
the bit items.

Random answer: Bitwise calculation.

0 = 00000000

1 = 00000001

2 = 00000010

3 = 00000011

4 = 00000100

5 = 00000101

You can use a bitwise calculation to determine which bits are turned on and
off.
Article that talks about the advantage of using bitwise data in a database.
http://www.sqlservercentral.com/colu...koperators.asp

Jay
Nov 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.