locked
asp.net c# sql database Delete command doesnt last RRS feed

  • Question

  • User1801854900 posted

    hi,

    i have a gridview connected to the sql database, and its over 1000 entries and very slow to refresh.  i want to delete whats in there.  i added this to a button click, which instantly clears out the contents of the gridview.  gone.  go to write again? and all of it still there, starts where it left off.  

    expected it to start adding at index 1.  what else is needed?  

    protected void Button2_Click(object sender, EventArgs e)
    {
    SqlDataSource1.DeleteCommand = "delete from [main5]";
    SqlDataSource1.Delete();
    }

    Monday, January 27, 2014 12:09 AM

Answers

  • User436416516 posted

    Hi,

    Afrer delete statement execute, try execute the below statement. then you will get expected result.

    DBCC CHECKIDENT('main5', RESEED, 0)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 27, 2014 5:14 AM

All replies

  • User436416516 posted

    Hi,

    Afrer delete statement execute, try execute the below statement. then you will get expected result.

    DBCC CHECKIDENT('main5', RESEED, 0)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 27, 2014 5:14 AM
  • User1801854900 posted

    yes that fixed it!!  no idea how you did this...  i added the string to the delete statement and then did delete() again, and it cleared it out, starting at 1 again thanks so much!!

    Monday, January 27, 2014 12:16 PM