troubleshooting Question

i can not succeed to feed a Store Proc (with an identity column) with a Datatable from C# , what am i doing wrong ? .

Avatar of Erwin Pombett
Erwin PombettFlag for Switzerland asked on
Microsoft SQL Server
11 Comments1 Solution632 ViewsLast Modified:
Hello,

i'm stacked with the following problem:

From C# I'm trying to feed a store procedure MyStoreProc which has only one entry parameter that is a "TYPE AS TABLE"
my "TYPE AS TABLE" has id as first column which is declared as identity(1,1)

Now, in c# i've created a datatable which has the same number of columns (same header that columns name) that my "TYPE AS TABLE" including
the column for the id that i filled up with integers.
If I call my SP with the parameter which is the datatable , I receive the error:
      INSERT into an identity column not allowed on table variables

If I remove the id column from the datatable and I call my SP I receive the error
      Trying to pass a table-valued parameter with (X-1) column(s) where the corresponding user-defined table type requires (X) column(s).


how can i manage to call myStoreProc in order no to pass the id ?

thank you in advance for all your ideas, proposals.

toshi
ASKER CERTIFIED SOLUTION
Nitin Sontakke
Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros