Convert.ToBoolean in OD 19.4

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Convert.ToBoolean in OD 19.4

Post by wjstarck »

This code has been working for many years, but is suddenly broken in OD 19.4

Code: Select all

string command = "SELECT AddEnhancedMenuItems FROM anesthpreference";
return Convert.ToBoolean(DataCore.GetScalar(command));
So to get it working, I have to rewrite it as

Code: Select all

string command = "SELECT AddEnhancedMenuItems FROM anesthpreference";
string result = DataCore.GetScalar(command);
bool prefResult = Convert.ToBoolean(Convert.ToInt32(result));
return prefResult;
Why?
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: Convert.ToBoolean in OD 19.4

Post by cmcgehee »

Did you used to store AddEnhancedMenuItems as "true" and now you're storing it at "1"?
Chris McGehee
Open Dental Software
http://www.opendental.com
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Convert.ToBoolean in OD 19.4

Post by wjstarck »

Always stored as 1 or 0
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: Convert.ToBoolean in OD 19.4

Post by cmcgehee »

When I run Convert.ToBoolean("1") in C# 7.3 using .NET Framework 4.5.2 in Visual Studio 2019, it gives a FormatException. I cannot vouch for its behavior in older versions of C# or .NET.
Chris McGehee
Open Dental Software
http://www.opendental.com
User avatar
wjstarck
Posts: 949
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Convert.ToBoolean in OD 19.4

Post by wjstarck »

Chris-

I store those as tinyints in my tables instead of bools. Could that be the problem?
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA
User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: Convert.ToBoolean in OD 19.4

Post by cmcgehee »

I don't think so. We store bools as tinyints as well.
Chris McGehee
Open Dental Software
http://www.opendental.com
Post Reply