are you doing exactly what you are written. then since the value of idno changes in the first execution then there is no chances to execute the command again. as after the first execution the idno value will not match with the textbox value. you can debug and test it.
can you try like this.
connDatagrid = New SqlConnection()
connDatagrid.ConnectionString = ConnectionString
connDatagrid.Open()
While Sum <> 0
Try
For IdLoop = 1 To DepartLoop
MessageBox.Show(IdLoop)
myCommand = new SQLCommand()
myCommand.Connection = connDatagrid
myCommand.CommandText = "update vnstelefon set idnr = idnr + 1" + " where idnr = " + TextBoxIDnr.Text.ToString + " and orginal = '" + ComboBoxDepart.SelectedItem + "'"
myCommand.ExecuteNonQuery()
myCommand.Dispose()
Next IdLoop
Catch myerror As MySqlException
MessageBox.Show(TextBoxName.Text & " kunde inte laggas till " & myerror.Message)
End Try
'MessageBox.Show(myCommand.ExecuteNonQuery)
MessageBox.Show(myCommand.CommandText)
DepartLoop = DepartLoop + 1
TextBoxIDnr.Text = DepartLoop
Sum = Sum - 1
End While
connDatagrid.Close()
|