Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 4th, 2003, 05:45 AM
Authorized User
 
Join Date: Jun 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't convert type 'bool' to 'int'

Hello ppl,

Chapter 5, User and Authentication, page 173, method Update:

public bool Update()
{
Configuration.ModuleSettings moduleSettings = Configuration.ModuleConfig.GetSettings();

Data.Role dataRole = new Data.Role(moduleSettings.ConnectionString);

return roleId = dataRole.Update(roleId, description);
}


This method causes 2 erros:

error CS0029: Cannot implicitly convert type 'bool' to 'int'
error CS0029: Cannot implicitly convert type 'int' to 'bool'

I understand implicit conversions, but I don't understand why this error doesn't come up in my downloaded code? What does it convert in theirs and not in mine?

Kim Gjerstad
__________________
Kim Gjerstad
 
Old July 9th, 2003, 04:07 AM
Friend of Wrox
 
Join Date: May 2003
Posts: 229
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Kim

It seems you have written this version of the code yourself.
Doing so you have made a mistake in the last line of the code.
the last line of your looks like this

return roleId = dataRole.Update(roleId, description);

the problem here is that you are assigning the return value
of "dataRole.Update" function which is of type bool to "roleId"
which is an int type variable.

This step is not needed so you can simply do away with the assignment
part so that the code looks only like this

return dataRole.Update(roleId, description);

and the entire function looks like this


        public bool Update()
        {
            Configuration.ModuleSettings moduleSettings = Configuration.ModuleConfig.GetSettings();
            Data.Role dataRole = new Data.Role( moduleSettings.ConnectionString );

            return dataRole.Update(roleId, description);
        }

this should resolve the problem.

Write back if there is anything else you wanna ask.

Ankur Verma
VC++ and .Net Expert
Wiley Tech Support
 
Old July 9th, 2003, 10:33 AM
Authorized User
 
Join Date: Jun 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thx, I got why!

Kim Gjerstad





Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot implecitly convert type bool to string vaidyapragati General .NET 1 May 4th, 2007 09:10 PM
Convert from bool Ric_H MySQL 1 May 22nd, 2006 11:55 PM
cant implicitly convert type int to bool muskaanbajaj BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 19th, 2005 04:57 PM
Cannot implicitly convert type int to bool muskaanbajaj General .NET 12 May 5th, 2005 03:57 AM
How to Convert a int in a bool with FormatStrings ShadowMoon Classic ASP Basics 2 October 26th, 2004 05:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.