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?
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
Re: storing checkbox rsponse in bit and binary
Quote:
Originally Posted by
jay patel
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.