CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2014
    Posts
    6

    storing checkbox rsponse in bit and binary

    Hello

    I have created one page in C#.net and there I have kept 6 different checkboxes to select option and then I want to convert this response into binary and want to store in binary format to database. so, how could I?
    I have already stored it in string as below but I want to store it in binary format so, any one can say me?

    Code:
    StringBuilder Selection1 = new StringBuilder();
        
                    foreach (ListItem item in Checkbox_c1.Items)
                    {
                        if (item.Selected)
                            Selection1.Append("1");
                        else
                            Selection1.Append("0");
                    }
         string cmbn1sequn = Selection1.ToString();
    but now I wanted to store it in binary format. so, how?

    and other question is that how should I have to write in sql query to store bit in database?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: storing checkbox rsponse in bit and binary

    Example with the bit field:
    Code:
    -- create a table
    USE [MyDB]
    GO
    CREATE TABLE  [dbo].[BitTest](
    	[BitField] [bit] NOT NULL
    ) ON [PRIMARY]
    
    GO
    -- insert a bit value
    INSERT INTO [MyDB].[dbo].[BitTest]
               ([BitField])
         VALUES
               (1)
    GO
    
    -- change bit value
    UPDATE [MyDB].[dbo].[BitTest]
    	SET [BitField] = 0
    GO
    Victor Nijegorodov

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: storing checkbox rsponse in bit and binary

    Quote Originally Posted by jay patel View Post
    I have created one page in C#.net and there I have kept 6 different checkboxes to select option and then I want to convert this response into binary and want to store in binary format to database. so, how could I?
    ...
    but now I wanted to store it in binary format. so, how?
    Have a look at this thread. The idea is starightforward.
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured