Click here to Skip to main content
15,881,631 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
These are two class files
public class Salary
{
    .
    .
    .
    public List<TripAllowanceDT> tripAllowancedt { get; set; }

}


public class TripAllowanceDT
{
    public int id { get; set; }
    public string BookingNumber { get; set; }
    public int NewBookingId { get; set; }
    public string TripAllowance { get; set; }
    public DateTime MultidayFromDate { get; set; }
    public int EmployeeId { get; set; }
}


This is the code for calling a stored procedure

  SqlConnection conn = new SqlConnection();
              conn.ConnectionString = ConfigurationManager.ConnectionStrings["DBConnect"].ConnectionString;
              conn.Open();
              SqlCommand sc = new SqlCommand("SP", conn);

sc.Parameters.AddWithValue("AllowanceDT", EmployeeSalary.tripAllowancedt);
             DataTable dt = new DataTable();
              SqlDataAdapter da = new SqlDataAdapter(sc);
              sc.CommandType = CommandType.StoredProcedure;
              da.Fill(dt);


What I have tried:

I have tried for another method and it is working there, I have debugged the code and check values in it with data type as well. And it's all fine.
I have also removed code for the table-valued parameter from the stored procedure.
I have just declared i.e
@AllowanceDT TableType_UpdateAllowance ReadOnly
Posted
Updated 9-Apr-19 5:07am

1 solution

You're trying to pass a "collection" as a parameter; there is no such support.
sc.Parameters.AddWithValue("AllowanceDT", EmployeeSalary.tripAllowancedt);

SqlDbType Enum (System.Data) | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900