title: How to execute Table SP in C#
body: <p>I looked at the SQLTeam website but now am having a new problem cause I have an IDENTITY column and their example does not.  </p>
  
  <p>I have SQL Server 2008 and VS 2008.  I am trying to execute the InsertPIF SP using C# and a table UDT, but am getting an exception.  I have looked at a SQLTeam website 
  example with a Table UDT, but their example doesn't have an identity column like mine does.</p>
  
  <p>However, their example table doesn't have an identity column like mine. 
  What I am trying to do should be simple.  I have tried many different variations of this, but essentially:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[InsertPIF] @InputFileParam parseInputFile READONLY
  AS
  INSERT dbo.ParentTable SELECT strRow FROM @InputFileParam
  GO
  </code></pre>
  
  <p>where</p>
  
  <pre><code>CREATE TABLE [dbo].[ParentTable](
      [ParentID] [int] IDENTITY(1,1) NOT NULL,
      [strInput] [varchar](8000) NULL,
  PRIMARY KEY NONCLUSTERED 
  (...)
  </code></pre>
  
  <p>and type:</p>
  
  <pre><code>CREATE TYPE [dbo].[parseInputFile] AS TABLE(
      [NumCols] [int] IDENTITY(1,1) NOT NULL,
      [strRow] [varchar](500) NOT NULL,
      PRIMARY KEY CLUSTERED 
  (...)
  </code></pre>
  
  <p>What I am trying to do is to execute the above SP to insert new records into the ParentTable.  Example:</p>
  
  <pre><code>INSERT INTO ParentTable(strInput) VALUES ('A3|BB|C|DDD')
  INSERT INTO ParentTable(strInput) VALUES ('A4|GOB|BLDY|GOOK')
  INSERT INTO ParentTable(strInput) VALUES ('A5|Hello|My|Darling')
  </code></pre>
  
  <p>Here is more of my C# code prior to the AppendData section:</p>
  
  <pre><code>DataTable dt = new DataTable();
  String[] header = myStringArray[0].Split('|');
  
  DataRow dr = dt.NewRow();
  DataColumn dc = new DataColumn();
  dc.DataType = typeof(Int32);
  dc.ColumnName = “NumCols”;
  dc.AutoIncrement=true;
  dt.Columns.Add(dc);
  
  DataColumn dc2 = new DataColumn();
  dc2.DataType = typeof(string);
  dc2.ColumnName = “strRow”;
  dt.Columns.Add(dc2);
  dr["NumCols"] = 1;
  dr["strRow"] = "AA|BBB|CC|DD|E";
  dt.Rows.Add(dr);
  
  ...
                  SqlConnection conn = new SqlConnection(connString);
                  SqlCommand cmd = conn.CreateCommand();
                  cmd.CommandText = "dbo.InsertPIF";
                  cmd.CommandType = CommandType.StoredProcedure;
                  cmd.Connection = conn;
                  SqlParameter param = cmd.Parameters.AddWithValue("@InputFileParam", SqlDbType.Structured);
  
          param.Value = dt;
          conn.Open();
          RowsAffected = cmd.ExecuteNonQuery();
  </code></pre>
  
  <p>I set identity to be turned on for the <code>ParentTable</code>, but it seems like I have to execute this each session, so I'm not sure how to remove identity requirement or else to make identity remain on.  Exception:</p>
  
  <p>INSERT into an identity column not allowed on table variables.  The data for table-valued parameter '@InputFileParam' doesn't conform to the table type of the parameter.</p>
  
  <p>How do I execute this SP?</p>