Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7631595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:23:40+00:00 2026-05-31T06:23:40+00:00

WebService.asmx.cs [WebMethod] public HashSet<callInfo> getCalls(string Date, string techID) { HashSet<callInfo> list = new HashSet<callInfo>();

  • 0

WebService.asmx.cs

[WebMethod]
public HashSet<callInfo> getCalls(string Date, string techID)
{
    HashSet<callInfo> list = new HashSet<callInfo>();
    var today = Convert.ToDateTime(Date);
    var tomorrow = today.AddDays(1).ToString("MM-dd-yyyy");
    var comm = new SqlCommand("Select RTrim(CallNbr), RTrim(CustNmbr), RTrim(AdrsCode), RTrim(SvcDescr), RTrim(SrvStat), RTrim(Customer_Reference), Convert(Varchar, ETADTE, 101), Convert(Varchar, ETATME, 108), RTrim(Address1), RTrim(City), RTrim(State), RTrim(Zip), Left(Phone1, 3) + '-' + SubString(Phone1, 5, 3) + '-' + SubString(Phone1, 9, 4) From SVC00200 Where ETADTE In ('" + Date + "','" + tomorrow +"') And TechID = '" + techID + "' And SrvStat Between '20D' And '59Z'", SQL01);
    SQL01.Open();
    SqlDataReader dr = comm.ExecuteReader();

    if (!dr.HasRows) { dr.Close(); SQL01.Close(); return null;}

        while (dr.Read())
        {
            callInfo ci = new callInfo
                              {
                                  callNumber = dr[0].ToString(),
                                  customer = dr[1].ToString(),
                                  adrsCode = dr[2].ToString(),
                                  svcDesc = dr[3].ToString(),
                                  srvStat = dr[4].ToString(),
                                  poNumber = dr[5].ToString(),
                                  etaDte = dr[6].ToString(),
                                  etaTime = dr[7].ToString(),
                                  address = dr[8].ToString(),
                                  city = dr[9].ToString(),
                                  state = dr[10].ToString(),
                                  zip = dr[11].ToString(),
                                  phone = dr[12].ToString()
                              };
            list.Add(ci);
        }

    dr.Close();
    SQL01.Close();
    return list;

}

Method attempting to consume that webservice and populate HashSet from getCalls()

private string getCalls()
{
    callInfo defaultCall = new callInfo() {callNumber = "None"};
    var calls = inst.getCalls(_date, _techID).DefaultIfEmpty(defaultCall).ToList();
    if (calls.First().callNumber == "None")
        return "None";
    foreach (callInfo info in calls)
    {
        try
        {
            var SQL = string.Format("Insert Or Ignore Into Calls Values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')", info.callNumber, info.customer, info.adrsCode, info.svcDesc, info.srvStat, info.poNumber, info.etaDte, info.etaTime, info.address, info.city, info.state, info.zip, info.phone);
            new SQLite(SQL, false);
        }
        catch (Exception ex)
        {
            return "Error " + ex.Message;
        }
    }
    return "Success";
}

var calls = inst.getCalls throws

“Unhandled Exception: System.ArgumentNullException: Argument cannot be
null. Parameter name: source”

The webmethod returns null when there are no calls just as it is supposed to. But even when I have a default if empty value declared, it still creates the null argument exception. How do I handle null return values?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:23:41+00:00Added an answer on May 31, 2026 at 6:23 am

    If inst.getCalls(_date, _techID) returns null isn’t it the following .DefaultIfEmpty(defaultCall).ToList() that causes the Exception?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webservice defined here: /app/AutocompleteManager.asmx [WebMethod] public string AutocompleteComposers() { return hey,
i have webservice with one method which recieves xml as string: [WebMethod] public int
i have a webmethod in my webservice public class Service : System.Web.Services.WebService { [WebMethod]
i've got the following simple webservice : [WebMethod()] public int Add(int a) { return
I understand that you cannot return a generic list in a standard .asmx webservice.
I have a webservice (asmx file) in a directory requiring form authentication When I
I have just tried adding a WebService (asmx based) from a WebForms project to
$.ajax({ type: POST, url: WebService.asmx/AddVisitor, data: {'fname':'dave', 'lname':'ward'}, contentType: application/json; charset=utf-8, dataType: json });
I need to connect to an asmx webservice using javascript. the webservice accepts and
I am working on creating a .asmx webservice to meet the specific needs of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.