Hello! I would like to ask if you guys know how to convert 1 to 00001?
For example, I have an item in my database with an ID of 00001. When I add another item again, it must increment already to 00002. But when I try adding one, the next ID saved is just 2. The zeros aren't on the left side.

The code is shown below

da = New OleDbDataAdapter("select  * from booklet", con)
        cb = New OleDbCommandBuilder
        dt = New DataTable
        da.Fill(dt)


        c = New OleDbCommand("Insert into booklet(booklet_num)values('" & txtNewBklet.Text & "')", con)
        c.Connection = con
        c.ExecuteNonQuery()



        For i = 1 To 25
            da = New OleDbDataAdapter("select  * from ticket order by ticket_num desc", con)
            cb = New OleDbCommandBuilder
            dt = New DataTable
            da.Fill(dt)


            'Me.txttic.ToString().PadLeft(4, "0")
            Me.txttic.Text = dt.Rows(0)("ticket_num") + 1

            c = New OleDbCommand("Insert into ticket(ticket_num,booklet_num) values('" & Me.txttic.Text & "', '" & Me.txtNewBklet.Text & "')", con)
            c.Connection = con
            c.ExecuteNonQuery()

        Next
       
        MsgBox("success")

The output in the database after the 00025 is 26 up to 50 only. If I add another again, it's just another 51-75 only. I can't seem to save it on a format like the 1st series of ticket number that I've added directly on the database with the format of 00001-00025. Can anyone help me? :(

Don't try to save leading zeroes. That's just a way to display, not to store, numbers 1,2,3 etc. and you already know how to use PadLeft(5, "0") function.

HTH

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.