Can anyone help me with this issue?
I keep getting the error message stating: "There is no argument given that corresponds to the required formal parameter 'SSN' of HomeController.GetCICO(string)"
This error seems to be originating from the following code snippet:
public JsonResult GetAllCICO()
{
var cicos = GetCICO().ToList();
var jsonResult = Json(new{data = cicos}, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return jsonResult;
}
The problematic method in question is the GetCICO function:
public List<CICO> GetCICO(string SSN)
{
List<CICO> cicos = new List<CICO>();
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString = str;
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = con;
cmd.CommandTimeout = 180;
cmd.CommandText = "SELECT * FROM source_ips WHERE ssn_or_tin = '"+SSN+"' ORDER BY dateTrans ASC";
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
if (sdr.HasRows)
{
while (sdr.Read())
{
CICO cico = new CICO()
{
ssn_or_tin = sdr["ssn_or_tin"] == DBNull.Value ? (double?)null : Convert.ToDouble(sdr["ssn_or_tin"]),
cusid = sdr["cusid"] == DBNull.Value ? (double?)null : Convert.ToDouble(sdr["cusid"]),
accountNo = sdr["accountNo"] == DBNull.Value ? (double?)null : Convert.ToDouble(sdr["accountNo"]),
dateTrans = sdr["dateTrans"].ToString(),
transCode = sdr["transCode"] == DBNull.Value ? (int?)null : Convert.ToInt32(sdr["transCode"]),
transdescription_1 = sdr["transdescription_1"].ToString(),
amount = sdr["amount"] == DBNull.Value ? (double?)null : Convert.ToDouble(sdr["amount"]),
cashin = sdr["cashin"] == DBNull.Value ? (double?)null : Convert.ToDouble(sdr["cashin"]),
cashout = sdr["cashout"] == DBNull.Value ? (double?)null : Convert.ToDouble(sdr["cashout"]),
source = sdr["source"].ToString()
};
cicos.Add(cico);
}
}
}
con.Close();
}
}
return cicos;
}
In addition, here is a snippet of my JavaScript code for further reference:
var SSNdata = { SSN: $("#SSN").val() };
$.ajax({
type: "POST",
url: "/Home/GetCICO",
data: SSNdata,
dataType: "json"
});