Click here to Skip to main content
16,006,768 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Listeners in VB.NET Pin
mr_lasseter25-Jul-06 12:54
mr_lasseter25-Jul-06 12:54 
QuestionStrange Error while inserting records Pin
mike_eps25-Jul-06 9:19
mike_eps25-Jul-06 9:19 
AnswerRe: Strange Error while inserting records Pin
mike_eps26-Jul-06 4:23
mike_eps26-Jul-06 4:23 
QuestionUpdating Primary Key after Record Deletion (Access 2003) Pin
Joshua Boyle25-Jul-06 8:49
Joshua Boyle25-Jul-06 8:49 
AnswerRe: Updating Primary Key after Record Deletion (Access 2003) Pin
ChandraRam25-Jul-06 9:03
ChandraRam25-Jul-06 9:03 
GeneralRe: Updating Primary Key after Record Deletion (Access 2003) Pin
Joshua Boyle25-Jul-06 10:07
Joshua Boyle25-Jul-06 10:07 
GeneralRe: Updating Primary Key after Record Deletion (Access 2003) Pin
ChandraRam25-Jul-06 10:12
ChandraRam25-Jul-06 10:12 
GeneralRe: Updating Primary Key after Record Deletion (Access 2003) [modified] Pin
Joshua Boyle25-Jul-06 10:32
Joshua Boyle25-Jul-06 10:32 
The following is the entire event handler for btnDelete_Click:

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteSelected.Click
    Dim strSQL As String = ""
    Dim nIndex As Integer = 0
    Dim nCount As Integer = 0

    If lstHistory.SelectedIndex < 0 Then
        MsgBox("You must first select the record you wish to delete.", MsgBoxStyle.Critical, "Selection Required")
    Else
        nIndex = lstHistory.SelectedIndex
        lstHistory.ClearSelected()
        strSQL = "DELETE FROM tblEvents WHERE ID = " + nIndex.ToString()

        Try
            oleCommand = New OleDbCommand()

            With oleCommand
                .Connection = New OleDbConnection(strConn)
                .Connection.Open()
                .CommandText = strSQL
            End With

            oleDataAdapter = New OleDb.OleDbDataAdapter(oleCommand)
            oleCommand.ExecuteNonQuery()
            oleCommand.Connection.Close()

            PopulateHistory()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Try
            oleCommand = New OleDbCommand()
            oleCommand.Connection = New OleDbConnection(strConn)
            oleCommand.Connection.Open()

            For nCount = 0 To nRecords
                oleCommand.CommandText = "UPDATE tblEvents (ID) VALUES (" + nCount + ")"
                oleDataAdapter = New OleDbDataAdapter(oleCommand)
            Next

            oleCommand.Connection.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End If
End Sub


The UPDATE SQL string is, indeed, within a For loop. I update the ID VALUE of that string with the counter (nCount) of the For loop in attempt to manually update each tuple's ID.



-- modified at 16:32 Tuesday 25th July, 2006
GeneralRe: Updating Primary Key after Record Deletion (Access 2003) Pin
ChandraRam25-Jul-06 18:40
ChandraRam25-Jul-06 18:40 
Questionpopulating a dropdown list from an arraylist Pin
ssbelfast25-Jul-06 8:46
ssbelfast25-Jul-06 8:46 
AnswerRe: populating a dropdown list from an arraylist Pin
mtone25-Jul-06 9:25
mtone25-Jul-06 9:25 
QuestionHow to consume datagrid events Pin
_Chosen25-Jul-06 8:41
_Chosen25-Jul-06 8:41 
Questionwrite directly to disk drive Pin
cesur13325-Jul-06 5:00
cesur13325-Jul-06 5:00 
Questionsaving a file using vb6 Pin
yaserhamdy200625-Jul-06 1:58
yaserhamdy200625-Jul-06 1:58 
QuestionColumn Header of Datagrid Pin
Girish48125-Jul-06 1:41
Girish48125-Jul-06 1:41 
AnswerRe: Column Header of Datagrid Pin
_Chosen25-Jul-06 8:52
_Chosen25-Jul-06 8:52 
AnswerRe: Column Header of Datagrid Pin
mr_lasseter25-Jul-06 9:49
mr_lasseter25-Jul-06 9:49 
QuestionData grid Pin
_Chosen25-Jul-06 1:25
_Chosen25-Jul-06 1:25 
Questionimplement different file formats in VB.net Pin
divyaswati25-Jul-06 0:07
divyaswati25-Jul-06 0:07 
AnswerRe: implement different file formats in VB.net Pin
Colin Angus Mackay25-Jul-06 4:02
Colin Angus Mackay25-Jul-06 4:02 
GeneralRe: implement different file formats in VB.net Pin
Girish48125-Jul-06 17:48
Girish48125-Jul-06 17:48 
GeneralRe: implement different file formats in VB.net Pin
Colin Angus Mackay25-Jul-06 20:00
Colin Angus Mackay25-Jul-06 20:00 
GeneralRe: implement different file formats in VB.net Pin
divyaswati25-Jul-06 19:22
divyaswati25-Jul-06 19:22 
GeneralRe: implement different file formats in VB.net Pin
Colin Angus Mackay25-Jul-06 20:03
Colin Angus Mackay25-Jul-06 20:03 
Questionhow to populate a checkbox in datagrid Pin
kerrieitdev25-Jul-06 0:04
kerrieitdev25-Jul-06 0:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.