Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Dealing with bit datatype..


Message #1 by miss ruby <unix_box@y...> on Wed, 29 May 2002 19:44:14 -0700 (PDT)
hello guys...


1'm using SQL 2000 Server database.. And we always do
like this to retrieve data..



string myName=dr["Name"].ToString();
int myID=(int)dr["UserID"];


What about bit datatype???? how can i do???



thanks..



=====
miss ruby
malaysia

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
Message #2 by "Minh T. Nguyen" <nguyentriminh@y...> on Wed, 29 May 2002 21:23:20 -0700
Miss Ruby,

	Have you tried to use the bool datatype?

Minh.

-----Original Message-----
From: miss ruby [mailto:unix_box@y...] 
Sent: Wednesday, May 29, 2002 7:44 PM
To: aspx_beginners
Subject: [aspx_beginners] Dealing with bit datatype..


hello guys...


1'm using SQL 2000 Server database.. And we always do
like this to retrieve data..



string myName=dr["Name"].ToString();
int myID=(int)dr["UserID"];


What about bit datatype???? how can i do???



thanks..



=====
miss ruby
malaysia

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


Message #3 by miss ruby <unix_box@y...> on Wed, 29 May 2002 22:21:49 -0700 (PDT)

No.. i not try to use bool data type...can you explain
it more/??

thanks..




--- "Minh T. Nguyen" <nguyentriminh@y...> wrote:
> Miss Ruby,
> 
> 	Have you tried to use the bool datatype?
> 
> Minh.
> 
> -----Original Message-----
> From: miss ruby [mailto:unix_box@y...] 
> Sent: Wednesday, May 29, 2002 7:44 PM
> To: aspx_beginners
> Subject: [aspx_beginners] Dealing with bit
> datatype..
> 
> 
> hello guys...
> 
> 
> 1'm using SQL 2000 Server database.. And we always
> do
> like this to retrieve data..
> 
> 
> 
> string myName=dr["Name"].ToString();
> int myID=(int)dr["UserID"];
> 
> 
> What about bit datatype???? how can i do???
> 
> 
> 
> thanks..
> 
> 
> 
> =====
> miss ruby
> malaysia
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> 
> 
> 


=====
miss ruby
malaysia

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
Message #4 by "Minh T. Nguyen" <nguyentriminh@y...> on Wed, 29 May 2002 23:20:52 -0700
Miss Ruby,

	The bool data type is a data type that can hold only two values:
true/false. Having said that, it's usually the data type used to store
binary data that can have only two states. So, I would guess that that's
the data type to use to get data back from a bit-field from your SQL
Server. Give this a try:

	bool myBit = (bool) dr["MyBitField"];

	if (myBit)
		myTextBox.Text = "Bit is set";
	else
		myTextBox.Text = "Bit is not set";


Hope this works for you,
Minh.


-----Original Message-----
From: miss ruby [mailto:unix_box@y...] 
Sent: Wednesday, May 29, 2002 10:22 PM
To: aspx_beginners
Subject: [aspx_beginners] RE: Dealing with bit datatype..




No.. i not try to use bool data type...can you explain
it more/??

thanks..




--- "Minh T. Nguyen" <nguyentriminh@y...> wrote:
> Miss Ruby,
> 
> 	Have you tried to use the bool datatype?
> 
> Minh.
> 
> -----Original Message-----
> From: miss ruby [mailto:unix_box@y...] 
> Sent: Wednesday, May 29, 2002 7:44 PM
> To: aspx_beginners
> Subject: [aspx_beginners] Dealing with bit
> datatype..
> 
> 
> hello guys...
> 
> 
> 1'm using SQL 2000 Server database.. And we always
> do
> like this to retrieve data..
> 
> 
> 
> string myName=dr["Name"].ToString();
> int myID=(int)dr["UserID"];
> 
> 
> What about bit datatype???? how can i do???
> 
> 
> 
> thanks..
> 
> 
> 
> =====
> miss ruby
> malaysia
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> 
> 
> 


=====
miss ruby
malaysia

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com


Message #5 by miss ruby <unix_box@y...> on Thu, 30 May 2002 00:54:05 -0700 (PDT)

hi...

you give me a great sample dealing with bool data
type. it's very helpfull. i will try it..

Anyway.. what about bit data type.. Anyone know to
dealing with this data type???



thanks alot...




--- "Minh T. Nguyen" <nguyentriminh@y...> wrote:
> Miss Ruby,
> 
> 	The bool data type is a data type that can hold
> only two values:
> true/false. Having said that, it's usually the data
> type used to store
> binary data that can have only two states. So, I
> would guess that that's
> the data type to use to get data back from a
> bit-field from your SQL
> Server. Give this a try:
> 
> 	bool myBit = (bool) dr["MyBitField"];
> 
> 	if (myBit)
> 		myTextBox.Text = "Bit is set";
> 	else
> 		myTextBox.Text = "Bit is not set";
> 
> 
> Hope this works for you,
> Minh.
> 
> 
> -----Original Message-----
> From: miss ruby [mailto:unix_box@y...] 
> Sent: Wednesday, May 29, 2002 10:22 PM
> To: aspx_beginners
> Subject: [aspx_beginners] RE: Dealing with bit
> datatype..
> 
> 
> 
> 
> No.. i not try to use bool data type...can you
> explain
> it more/??
> 
> thanks..
> 
> 
> 
> 
> --- "Minh T. Nguyen" <nguyentriminh@y...>
> wrote:
> > Miss Ruby,
> > 
> > 	Have you tried to use the bool datatype?
> > 
> > Minh.
> > 
> > -----Original Message-----
> > From: miss ruby [mailto:unix_box@y...] 
> > Sent: Wednesday, May 29, 2002 7:44 PM
> > To: aspx_beginners
> > Subject: [aspx_beginners] Dealing with bit
> > datatype..
> > 
> > 
> > hello guys...
> > 
> > 
> > 1'm using SQL 2000 Server database.. And we always
> > do
> > like this to retrieve data..
> > 
> > 
> > 
> > string myName=dr["Name"].ToString();
> > int myID=(int)dr["UserID"];
> > 
> > 
> > What about bit datatype???? how can i do???
> > 
> > 
> > 
> > thanks..
> > 
> > 
> > 
> > =====
> > miss ruby
> > malaysia
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! - Official partner of 2002 FIFA World Cup
> > http://fifaworldcup.yahoo.com
> > 
> > 
> > 
> 
> 
> =====
> miss ruby
> malaysia
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
> 
> 
> 


=====
miss ruby
malaysia

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
Message #6 by "Kyle" <Kyle@T...> on Thu, 30 May 2002 07:25:31 -0400
Miss Ruby,

The bit data type is the bool data type, just stored more efficiently in
SQL Server. The bit and bool data types can only have two states, on or
off.  It is documented that if several bits are stored consecutively in
a SQL table, SQL might combine them together as a byte for more
efficient storage. That is determined internally by SQL Server and there
is no guarantee of this. The way I read it is, if a single bit is placed
between two other data types in a SQL table it would get stored as a
byte.

I read a bit value for a radio button selection into a row using a
SQLDataReader with syntax like this:

r["RadioButtonName"] =3D drTableName.GetBoolean(0);

r["RadioButtonName"] is a bool datatype, there is no bit datatype in C#.
To write the value back out to the SQL table I have to convert it to a
byte with syntax like this:

cmd.CommandText =3D "UPDATE tablename SET RadioButtonName =3D " +
Convert.ToByte(rbnRadioButtonName.Checked) ....

I tried converting it to a bool data type to write it out to the SQL
database but got 'Invalid Column Name True' returned as an exception. So
I suspect all my bit data types are being written as single bytes.

I hope this helps you Miss Ruby.

Minh,

Do you know of a way to get SQL Server to take advantage of the
efficient bit storage? You are so good at challenges that I couldn't
resist that question.

Kyle


 


-----Original Message-----
From: miss ruby [mailto:unix_box@y...]
Sent: Thursday, May 30, 2002 3:54 AM
To: aspx_beginners
Subject: [aspx_beginners] RE: Dealing with bit datatype..



hi...

you give me a great sample dealing with bool data
type. it's very helpfull. i will try it..

Anyway.. what about bit data type.. Anyone know to
dealing with this data type???



thanks alot...




--- "Minh T. Nguyen" <nguyentriminh@y...> wrote:
> Miss Ruby,
>
> 	The bool data type is a data type that can hold
> only two values:
> true/false. Having said that, it's usually the data
> type used to store
> binary data that can have only two states. So, I
> would guess that that's
> the data type to use to get data back from a
> bit-field from your SQL
> Server. Give this a try:
>
> 	bool myBit =3D (bool) dr["MyBitField"];
>
> 	if (myBit)
> 		myTextBox.Text =3D "Bit is set";
> 	else
> 		myTextBox.Text =3D "Bit is not set";
>
>
> Hope this works for you,
> Minh.
>
>
> -----Original Message-----
> From: miss ruby [mailto:unix_box@y...]
> Sent: Wednesday, May 29, 2002 10:22 PM
> To: aspx_beginners
> Subject: [aspx_beginners] RE: Dealing with bit
> datatype..
>
>
>
>
> No.. i not try to use bool data type...can you
> explain
> it more/??
>
> thanks..
>
>
>
>
> --- "Minh T. Nguyen" <nguyentriminh@y...>
> wrote:
> > Miss Ruby,
> >
> > 	Have you tried to use the bool datatype?
> >
> > Minh.
> >
> > -----Original Message-----
> > From: miss ruby [mailto:unix_box@y...]
> > Sent: Wednesday, May 29, 2002 7:44 PM
> > To: aspx_beginners
> > Subject: [aspx_beginners] Dealing with bit
> > datatype..
> >
> >
> > hello guys...
> >
> >
> > 1'm using SQL 2000 Server database.. And we always
> > do
> > like this to retrieve data..
> >
> >
> >
> > string myName=3Ddr["Name"].ToString();
> > int myID=3D(int)dr["UserID"];
> >
> >
> > What about bit datatype???? how can i do???
> >
> >
> >
> > thanks..
> >
> >
> >
> > =3D=3D=3D=3D=3D
> > miss ruby
> > malaysia
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! - Official partner of 2002 FIFA World Cup
> > http://fifaworldcup.yahoo.com
> >
> >
> >
>
>
> =3D=3D=3D=3D=3D
> miss ruby
> malaysia
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
>
>
>


=3D=3D=3D=3D=3D
miss ruby
malaysia

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

Message #7 by "Minh T. Nguyen" <nguyentriminh@y...> on Thu, 30 May 2002 08:04:48 -0700
Kyle,

	Sorry, no, I don't. I am not that much of a database person. 

Minh.

-----Original Message-----
From: Kyle [mailto:Kyle@T...] 
Sent: Thursday, May 30, 2002 4:26 AM
To: aspx_beginners
Subject: [aspx_beginners] RE: Dealing with bit datatype..

Minh,

Do you know of a way to get SQL Server to take advantage of the
efficient bit storage? You are so good at challenges that I couldn't
resist that question.

Kyle

Message #8 by "Kyle" <Kyle@T...> on Thu, 30 May 2002 11:09:55 -0400
Not yet anyway. :-)

-----Original Message-----
From: Minh T. Nguyen [mailto:nguyentriminh@y...]
Sent: Thursday, May 30, 2002 11:05 AM
To: aspx_beginners
Subject: [aspx_beginners] RE: Dealing with bit datatype..

Kyle,

	Sorry, no, I don't. I am not that much of a database person.

Minh.

-----Original Message-----
From: Kyle [mailto:Kyle@T...]
Sent: Thursday, May 30, 2002 4:26 AM
To: aspx_beginners
Subject: [aspx_beginners] RE: Dealing with bit datatype..

Minh,

Do you know of a way to get SQL Server to take advantage of the
efficient bit storage? You are so good at challenges that I couldn't
resist that question.

Kyle



  Return to Index