My program fail to generate the auto ID on my text can help me.

Private Sub getNextNumber()
        If Not app.State = ConnectionState.Open Then
            'open connection
            app.Open()
        End If

        Dim da As New OleDb.OleDbDataAdapter("select top 1 ID from ADMIN ORDER BY ID desc;", app)
        Dim dt As New DataTable
        'fill data to datatable
        da.Fill(dt)
        app.Close()

        If dt.Rows.Count > 0 Then
            txtID.Text = (Val(dt.Rows(0)(0)) + 1).ToString.PadLeft(5, "A")
        Else
            txtID.Text = "1".PadLeft(5, "A")
        End If
    End Sub

Are you using SQL or MySql? Both haev different usages to get the last id inserted into a table, which is the easiest and fastest way to go. Just get the last from a swl statement and add it to your textbox.

commented: i am using ms access database +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.