Convert.ToBoolean in OD 19.4

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

Convert.ToBoolean in OD 19.4

Post by wjstarck » Tue Dec 31, 2019 8:15 pm

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 » Wed Jan 01, 2020 8:01 am

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: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Convert.ToBoolean in OD 19.4

Post by wjstarck » Wed Jan 01, 2020 10:13 am

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 » Thu Jan 02, 2020 7:51 am

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: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Convert.ToBoolean in OD 19.4

Post by wjstarck » Fri Jan 03, 2020 10:05 am

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 » Mon Jan 06, 2020 7:40 am

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

Post Reply