locked
Problems with primary Key in MS SQL RRS feed

  • Question

  • User336760158 posted

    I am using an insert command into a data field designated as a primary field

    The id was incrementing one a at time but at 447 it jumped to 1447 then at 1471 it jumped to 2461

    any ideas why this would happen??. No records have been deleted

    this is the insert code

       

    if (Page.IsValid)

            {

     SqlConnection objConn = new SqlConnection(ConfigurationSettings.AppSettings["DSN"]);

     SqlCommand objCmd;

               

    SqlDataReader objRdr;

               

    SqlParameter prm;

               

    String strCmd;

            

                objCmd =

    new SqlCommand("INSERT INTO Location " +

               

    "(LocationState, LASurvey2 , LASurvey3, LASurvey4, LASurvey5, LASurvey6, UserID, " +

               

    " LocationName, LocationStreet, LocationTown, LocationPostCode, LANotes5, LANotes6, LANotes7, RenewalDate, DateRequired, LANotes10, LANotes11, LANotes12, LANotes13, LANotes14,LANotes15, LANotes16, LANotes17, LANotes18, LANotes19, LANotes20, LANotes21, LANotes22, LANotes23, LANotes24, LANotes25,LANotes26, LANotes27, LANotes28, LANotes29, LANotes30, LANotes31, LANotes32, LANotes33, LANotes34, LANotes35, LANotes36,LANotes37, DateInspected, DateMailed, LANotes40, LANotes42,LANotes43,DatePlanned" +

               

    ",DateEntered, SurveyorsNotes)" +

               

    "VALUES(" +

               

    " @LASurvey1, @LASurvey2 , @LASurvey3, @LASurvey4, @LASurvey5, @LASurvey6,@LASurvey6, " +

               

    " @LANotes1, @LANotes2, @LANotes3, @LANotes4, @LANotes5, @LANotes6, @LANotes7, @LANotes8, @LANotes9, @LANotes10, @LANotes11, @LANotes12, @LANotes13, @LANotes14,@LANotes15, @LANotes16, @LANotes17, @LANotes18, @LANotes19, @LANotes20, @LANotes21, @LANotes22, @LANotes23, @LANotes24, @LANotes25,@LANotes26, @LANotes27, @LANotes28, @LANotes29, @LANotes30, @LANotes31, @LANotes32, @LANotes33, @LANotes34, @LANotes35, @LANotes36, @LANotes37, @LANotes38, @LANotes39, @LANotes40, @LANotes41, @LANotes42,@LANotes43" +

               

    ",@DateEntered, @SurveyorsNotes); SELECT SCOPE_IDENTITY();", objConn);

    Tuesday, May 31, 2016 4:13 AM

Answers

All replies