As the title suggests, I want to pass table valued parameter which is DataTable from C#. I am using SQLServer 2012.
Here is how I defined Table Valued Parameter in SQL:
Create Type SchoolTableType as Table
(
SchoolID int primary key,
SchoolName nvarchar(50),
LocationID int
)
Here is the procedure
Create Proc spInsertSchool
@schoolDataTableVariable SchoolTableType readonly
as
begin
Insert into School
Select * from @schoolDataTableVariable
end
Here is how i am calling that stored procedure from C#
DbParameter[] param = new DbParameter[] { };
adapter.CallActionStoredProcedure("SpInsertSchool", param);
What my question is I dont know how to pass DataTable as parameter to StoredProcedure.