Using a Stored Procedure To Generate Primary Key RRS feed

  • Question

  • User-677746510 posted

    I'm creating a web application using a web form which essentially transfers data from an excel sheet to a table. I'm using the EPPlus library to do all of that, and have a working connection. My question is how do I use an already existing stored procedure for determining my primary key, and implement that into my application? What does that look like? Sorry if this is very simple, but I am new to ASP.NET and C#. Thanks!

    Thursday, June 15, 2017 6:31 PM

All replies

  • User753101303 posted


    Which db are you using? What does this existing procedure ? Usually generating a new primary key value is a db built in feature. For example with SQL Server :


    If you have been told to use an existing procedure it should already handle this correctly. Usually in case you need it, the procedure usually returns the newly inserted id (ask them how, you have multiple ways to return this value).

    Or give some more details if you need further help.

    Thursday, June 15, 2017 6:55 PM
  • User364663285 posted

    If you're using SQL server, you can define column as Identity to let database create the key for you.

    If You're using Oracle, you can create a sequence for such purpose.

    Friday, June 23, 2017 8:37 AM