Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2003, 12:09 AM
Authorized User
 
Join Date: Dec 2003
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default how to read checkboxlist

hi everybody,

my problem is:

i have one dinamic checkboxlist. User is allow to check more than 1 .
I don't know how to read the data as the data will be use in sql statement.


__________________
Suzila
 
Old December 18th, 2003, 04:12 PM
Registered User
 
Join Date: Nov 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

run a for-next loop on the array.
reading each check list's values one by one.
and put the results in an array of boolean.

then use this function to translate the 1-0-1-..
combination in the array to an integer.

and then use simple SQL line to insert this integer to
the database.


---------- code ------------------

 Private Function make_int_no(ByVal arr As Boolean(), ByVal size As Integer) As Integer
        Dim result As Integer = 0
        Dim i As Integer
        For i = 0 To size - 1
            result = result + arr(i) * (2 ^ i)
        Next
        Return (-result) ' because true is -1
    End Function

----------------------------------------


that's it!
hope it helped,
and im not too mysterious here.. :)



 
Old December 18th, 2003, 05:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jlick
Default

I don't like storing Boolean data this way. It is the most efficient, but it is very hard to read the data if you are using SQL tools. Also it is very difficult if you want to search. I would personally store each Boolean in a char(1) or a bit data type. SQL Server will optimize how it stores bits, and if there are < 9 in a table they will be consolidated to a byte for you. But you still can access/view them as bits. The only down side is that you can't index them. But an index on a Boolean type isn't very useful, as it really only splits the data into two groups anyway.


John R Lick
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckboxList onselectindexchanged rlb ASP.NET 2.0 Professional 1 August 13th, 2008 12:56 PM
Checkboxlist epkgupta Visual Studio 2005 0 March 11th, 2008 05:31 AM
Get Values from Checkboxlist derekl ASP.NET 1.0 and 1.1 Basics 3 May 26th, 2006 09:46 AM
CheckBoxList stu9820 ASP.NET 1.0 and 1.1 Basics 10 May 25th, 2006 08:15 PM
CheckBoxList eddiema VS.NET 2002/2003 1 April 9th, 2004 09:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.