Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I am using Active=0 to save the record this error will occurred "Cannot convert type int to bool".
the database active is using bit datatype..
please give me the solution

Thanks& Regrds
G Ravinder Reddy.
Posted
Comments
_Amy 8-Jan-13 5:22am    
Change the Tag as SQL Server, if your question deals with SQL.

If you want 0 instaed of False the you have to modify your select query like

:
Select case(Active) 
            When 'False' Then 0
            When 'True' Then 1 End as Active
From YourTableName


if help full then accept the solution
 
Share this answer
 
Comments
_Amy 8-Jan-13 4:22am    
Voted 3. Reason, Tag is ASP.net.
I suspect that you're getting an error in your code, not from the database. In the DB, what you've done is fine, I use 1 and 0 for bits all the time. You can try using 'false' and see what happens, or post your code if you want us to fix it.
 
Share this answer
 
if your datatype is bit then in frontend you should use datatype as bool and value will be assigned like Active=false or Active = true instead of Active=0.
 
Share this answer
 
Comments
Gujula Ravindra Reddy 8-Jan-13 4:03am    
Now i am using same but i want active =0 what is the solution...?
Yugal Pandya 8-Jan-13 4:18am    
declare @Active bit
set @Active = 0
select @Active


from UI if you are passing true and false or 0 or 1 it doesn't matter but it's datatype must bool in UI, rest system will take care of bool datatype with bit datatype of database.
I am totally agree with Christian Graus.
Here you can try with this alternative.
C#
bool YourBooleanVariable = Active == 0 ? false : true;


Here we can check the variable Active and if it is 0 then make your variable(working) as false/true as per needed.

This is Ternary Operator[^].

--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900