Iam trying to pass an array to a method then using it to a Stored procedure
protected void Button1_Click(object sender, EventArgs e)
{
string[] names = new string[3] { "Matt", "Joanne", "Robert" };
string User = "Employee";
mav.AccessType(names,User);
}
METHOD:
public void AccessType(String[] ARR, String Userty)
{
SysCon.Open();
SqlCommand cmdC = new SqlCommand("sp_AccessTypes", SysCon);
cmdC.CommandType = CommandType.StoredProcedure;
cmdC.Parameters.AddWithValue("@ARRAY", ARR);
cmdC.Parameters.AddWithValue("@USER", Userty);
cmdC.ExecuteNonQuery();
SysCon.Close();
}
STORED PROC
ALTER PROCEDURE [dbo].[sp_AccessType]
-- Add the parameters for the stored procedure here
@ARRAY AccessType1 Readonly,
@USER nvarchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
INSERT INTO tbl_samplednd1(UserType,parameter1) SELECT * FROM @ARRAY
END
it gives an error:
No mapping exists from object type System.String[] to a known managed provider native type.
How to fix it? Thank you