Nyx Assasin Nyx Assasin - 3 months ago 15
MySQL Question

000000001 and so on as Unique ID

Good Afternoon.
I am creating a program that has the following Modules and they are:

Purchase Requisition,Purchase Order,Receiving Items and Stock Requisition and they have an initials of PR,PO,RI and SR respectively. Now why did i tell that? because of this.

Each module that i said earlier has there own transactions and each transactions has its own reference number or a data that will be used as unique id.

Now my question lies in the image below

enter image description here

How can I achieve that?(Preferably display it in textbox) I want this kind of Unique ID for each module I have.

Seriously I don't how to do it because this is my first time doing this.

If there is a pro's and con's for this, Its okay, I will set parameters for that.

I hope someone helps me.

Answer

This is my answer on my own question but anyways TYSM for those commentators who didn't answer my question instead give me a negative code.

Sorry Guys I just really need that code and for those who want this kind of code here it is.

 Dim con As MySqlConnection = New MySqlConnection("Your MySQL Connection")
        Dim cmd As MySqlCommand = New MySqlCommand("select Max(Column_Of_Unique_ID) as UniqueValue from TableName", con)
        Dim reader As MySqlDataReader
        con.Open()
        reader = cmd.ExecuteReader
        Try
            While reader.Read

                'If its Purchase Order then PO
                'If its Purchase Requisition then PR
                'If its Receiving Items then RI
                'If its Stock Requisition then SR

                TextBox1.Text = reader.GetString("UniqueValue")
                TextBox1.Text = TextBox1.Text.Replace("PO", "").Trim()
                TextBox1.Text = TextBox1.Text + 1
                If TextBox1.Text.Length = 1 Then
                    TextBox1.Text = "PO" & "0000000" & TextBox1.Text
                ElseIf TextBox1.Text.Length = 2 Then
                    TextBox1.Text = "PO" & "000000" & TextBox1.Text
                ElseIf TextBox1.Text.Length = 3 Then
                    TextBox1.Text = "PO" & "00000" & TextBox1.Text
                ElseIf TextBox1.Text.Length = 4 Then
                    TextBox1.Text = "PO" & "0000" & TextBox1.Text
                ElseIf TextBox1.Text.Length = 5 Then
                    TextBox1.Text = "PO" & "000" & TextBox1.Text
                ElseIf TextBox1.Text.Length = 6 Then
                    TextBox1.Text = "PO" & "00" & TextBox1.Text
                ElseIf TextBox1.Text.Length = 7 Then
                    TextBox1.Text = "PO" & "0" & TextBox1.Text
                ElseIf TextBox1.Text.Length = 8 Then
                    TextBox1.Text = "PO" & TextBox1.Text
                End If
            End While
        Catch
            TextBox1.Text = "PO00000001"
        End Try 
Comments