Q:

mysql inserts new record where record was just deleted

I am having a problem with insert in mySQL after deleting a record. The newly inserted record gets inserted before the other records, in the place that the previous record was deleted.
So, if I have three records like so:
SnippetNum  Snippet
1             #1
2             #2
3             #3

If I delete record #1, the next record gets inserted like so
SnippetNum   Snippet
4             #4
2             #2
3             #3

which is messing up how my records are displayed in a checkedListBox
Here is the code for displaying items in the checkedListBox
       private void RefreshCheckedListNoteSnippets() {
        AnesthNoteSnippets.Refresh();
        checkedListNoteSnippet.Items.Clear();
        for (int i = 0; i < AnesthNoteSnippets.List.Length; i++) {
            string command = "SELECT Snippet FROM anesthnotesnippet WHERE SnippetNum = " + AnesthNoteSnippets.List[i].SnippetNum + " ORDER BY SnippetNum ASC";
            string snippet = DataCore.GetScalar(command);
            if (snippet != String.Empty) {
                checkedListNoteSnippet.Items.Add(snippet, false);
            }
         }
      } 

And here is my insert into code:
public static void Insert(string snippet) {
    string command = "INSERT INTO anesthnotesnippet (Snippet)" +
        " VALUES ('" + snippet + "')";
    DataCore.GetScalar(command);

}

Any suggestions appreciated

A:

In SQL, rows have no guaranteed intrinsic sort order in the tables, the DBMS is free to put them where it wants.
If you need them sorted in a specific way, that's something you do on extraction, which you already appear to have in your select statement.
But, since you're only doing one snippet at a time anyway (making the order by superfluous), it looks like it will come down to the order specified by:
for (int i = 0; i < AnesthNoteSnippets.List.Length; i++)

That's where you need to be concentrating your focus, it's likely that AnesthNoteSnippets.List is not sorted the way you want.
Check into the AnesthNoteSnippets.Refresh() call to ensure that the list is appropriately sorted on refresh.

