SQLTeam.com | Weblogs | Forums

WebService.asmx with numeric fields,, date fields & Boolean fields

I am developing a web version of an app I previously completed on a local PC(my first attempt at developing a web app).
I am trying to learn by following a method demonstrated at the following link:
www._dot_c-sharpcorner.com/
blogs/
how-to-retrieve-data-using-ajax-in-asp-net
However, my SQL Server database includes Boolean fields, as well as numeric and DateTime fields. The only syntax errors in the WebService.asmx file are with the DateTime, numeric, and Boolean fields.

Date Example:
record.ProposalDate = SqlDataReader.GetDateTime(string.Format("{0:d/M/yyyy}", rdr["ProposalDate"]));

Boolean Example:
record.EquipAff = rdr["EquipAff"].ToString();

Numeric example:
record.TotalCost = rdr["TotalCost"].ToString();

Since I have no working example for syntax relating to numeric fields,, DateTime fields or Boolean fields, I don't know how to fix the error.
Hopefully, someone with more experience than I have will see this and know what I'm doing wrong.
Thanks in advance!

Would help if you shared the error :smirk: and the specific data type of those columns. We believe what you are saying but our eyes dont yet

With my limited knowledge of C# I don't think you should use .ToString() in all cases.

Boolean Example:
record.EquipAff = rdr["EquipAff"].ToBoolean();

Numeric example:
record.TotalCost = rdr["TotalCost"].ToDecimal();

Casting and type conversions - C# Programming Guide | Microsoft Docs

Unless you know the data type of the target columns this could also fail

Thanks...but I tried that.
When I did, I get the following message:
"'object' does not contain a definition for 'ToBoolean' and no extension method 'ToBoolean' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)"

"'object' does not contain a definition for 'ToBoolean' and no extension method 'ToBoolean' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)"

I confirmed that I created the target columns with the same type before submitting the question.

You are better off posting on a .net website. This is not a sql issue