Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6642625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:57:11+00:00 2026-05-25T23:57:11+00:00

This is for a helpdesk ticketing program I’m creating: When the user clicks to

  • 0

This is for a helpdesk ticketing program I’m creating:

When the user clicks to start a ticket I want to be able to display an autonumber from mysql that corresponds with the current ticket being filled out, so that the user can track their ticket later on. I have everything set up but I’m not too sure how I can display the Ticket ID in a textbox.

Right now I have it so that the query is being ran to get the next Ticket Id number when the form loads, but I’m not sure how to display it as text in the textbox.

    'QUERY FOR NEW ID TICKET NUMBER   
Private Sub Suggestions_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    Dim idQuery As String = "SELECT MAX(itID)+1 AS Expr1 FROM(TableName)"

    With cmd
        .Connection = conn
        .CommandText = idQuery
        .CommandType = CommandType.Text
    End With

    Try
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()
        Me.Close()
    Catch ex As Exception
        MsgBox(ex.ToString)
        conn.Close()
    End Try

Now I managed to change it to this but I’m still getting hung up cause I’m not sur eif it’s correct:

Dim conn As New MySqlConnection(connStr)
Dim cmd As New MySqlCommand()
Dim Reader As MySqlDataReader
Dim submitteddate As String

'QUERY FOR NEW ID TICKET NUMBER   
Private Sub Suggestions_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    Try
        Dim idQ As String = "INSERT INTO tblit (itID, ersBugIssue, ersSubject, ersBugCategory, ersBugDate, ersBugSubmittedby, ersBugOrHelp )" & _
                                "VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL);"
        Dim cmd As new SQLCommand()
        With cmd
            .Connection = conn
            .CommandText = idQ
        End With

        conn.Open()
        cmd.ExecuteNonQuery()
        cmd.CommandText = "SELECT LAST_INSERT_ID() as NewTicketID"
        Dim Reader As SqlDataReader = cmd.ExecuteReader()
        Reader.Read()
        MsgBox(Reader("NewTicketID"))
        Reader.Close()

        conn.Close()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:57:12+00:00Added an answer on May 25, 2026 at 11:57 pm

    "SELECT MAX(itID)+1 AS Expr1 FROM(TableName)"

    Is a bad idea, you will run into concurrency issues very quickly.
    You should run the following SQL statements instead.

    INSERT INTO tablename (ID, morefields) 
      VALUES (NULL, real_values_or_place_holders);
    SELECT LAST_INSERT_ID() as NewTicketID;
    -- After the ticket is complete
    UPDATE tablename SET morefields = <thedata> WHERE id = NewTicketID 
    
    -- If the ticket gets cancelled:
    DELETE FROM tablename WHERE id = NewTicketID
    

    If you do it like that you will never run into issues with duplicate or wrong TicketID being issued.

    If you do a select, you cannot say it’s a nonQuery.

    Use the following code

    Dim cmd As New SqlCommand()
    cmd.Connection = conn
    cmd.CommandText = "SELECT LAST_INSERT_ID() AS NewTicketID"
    Dim reader As SqlDataReader = cmd.ExecuteReader()
    reader.Read
    MsgBox(reader("NewTicketID"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following issue: I want to display Tickets from a helpdesk system
I want to create a small helpdesk ticket control system at work, that would
Scenario: In an e-commerce system, a helpdesk user should be able to impersonate or
This is my first post here and I wanted to get some input from
All I'm after doing is this: SELECT CallTypeID, Count(CallTypeID) as NumberOfCalls FROM [Helpdesk_HR].[dbo].[CallHeader] WHERE
I'm writing a help desk pipe handler to pipe incoming e-mails as helpdesk ticket
I am doing a helpdesk application on android. I want to implement a notification
This is essentially what I want to do: public abstract class Uniform<T> { public
Creating a web interface so our helpdesk can create users and setup some of
This is a bit of a long shot, but if anyone can figure it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.