943,550 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Marked Solved
  • Views: 22156
  • ASP.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Jan 10th, 2008
0

how to convert true/false to bit

Expand Post »
HII,
i have a column in sql srver 2000 of data type bit.I have a checkbox in my page. i want to assign bit value to the column when the check box is checked and un checked,but i am getting errors when assigning true /false to the column.
Similar Threads
Reputation Points: 25
Solved Threads: 29
Posting Whiz
greeny_1984 is offline Offline
372 posts
since Apr 2007
Jan 10th, 2008
0

Re: how to convert true/false to bit

Datatype bit takes the value 0 or 1.....if true then 1
if false then 0
Reputation Points: 10
Solved Threads: 2
Light Poster
btech_Saurabh is offline Offline
39 posts
since Jan 2008
Jan 10th, 2008
0

Re: how to convert true/false to bit

when iam assigning false to the coulmn iam getting error
The name 'False' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
here is my code
if (facultychecked.Checked == true)
{
anndept.announceToFaculty =true;
}
else
{
anndept.announceToFaculty =false;
}
AnnouncementManager.CreateAnnouncement(anndept);

}
Reputation Points: 25
Solved Threads: 29
Posting Whiz
greeny_1984 is offline Offline
372 posts
since Apr 2007
Jan 10th, 2008
0

Re: how to convert true/false to bit

yes this is because.......it consist only true or false.....if 1 then true and if 0 then false

ur code must b like this

if (facultychecked.Checked == true)
{
anndept.announceToFaculty =1;
}
else
{
anndept.announceToFaculty =0;
}
AnnouncementManager.CreateAnnouncement(anndept);
}

if u pass 1 (or greater than 1)to ur bit datatype column....then it make is as True
if u pass 0 to ur bit datatype column in sqlserver then....it make it as false.....
Pass (1 or 0 ) value.....it automatically....insert True or False
Reputation Points: 10
Solved Threads: 2
Light Poster
btech_Saurabh is offline Offline
39 posts
since Jan 2008
Jan 10th, 2008
0

Re: how to convert true/false to bit

when iam using 1 and 0 iam getting error
CS0031: Constant value '1' cannot be converted to a 'bool'
if (facultychecked.Checked == true)
{
anndept.announceToFaculty =1;
}
else
{
anndept.announceToFaculty =0;
}
Reputation Points: 25
Solved Threads: 29
Posting Whiz
greeny_1984 is offline Offline
372 posts
since Apr 2007
Jan 10th, 2008
0

Re: how to convert true/false to bit

u can not assign 1 or 0 to a bool type variable.......
use Int type variable......and then assign 1 or 0
Reputation Points: 10
Solved Threads: 2
Light Poster
btech_Saurabh is offline Offline
39 posts
since Jan 2008
Jan 10th, 2008
0

Re: how to convert true/false to bit

can u explain more clearly
Reputation Points: 25
Solved Threads: 29
Posting Whiz
greeny_1984 is offline Offline
372 posts
since Apr 2007
Jan 10th, 2008
0

Re: how to convert true/false to bit

do this thing.....take one int type variable....


Int32 i;
if (facultychecked.Checked == true)
{
i =1;
}
else
{
i=0;
}

and now u have ur value in "i" ....insert the value of "i" in ur bit type column of ur table....
Reputation Points: 10
Solved Threads: 2
Light Poster
btech_Saurabh is offline Offline
39 posts
since Jan 2008
Jan 10th, 2008
0

Re: how to convert true/false to bit

if (facultychecked.Checked == true)
{
k = 1;

}
else
{
k = 0;
}
anndept.announceToFaculty = k;
iam getting error
CS0029: Cannot implicitly convert type 'int' to 'bool'
Reputation Points: 25
Solved Threads: 29
Posting Whiz
greeny_1984 is offline Offline
372 posts
since Apr 2007
Jan 10th, 2008
0

Re: how to convert true/false to bit

"anndept.announceToFaculty " this function is of bool type change this function dear.........
change this function dear........
Last edited by btech_Saurabh; Jan 10th, 2008 at 8:06 am.
Reputation Points: 10
Solved Threads: 2
Light Poster
btech_Saurabh is offline Offline
39 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: .net nutch.
Next Thread in ASP.NET Forum Timeline: Hi Help me i am new to asp.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC