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 5930519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:33:58+00:00 2026-05-22T14:33:58+00:00

I have a database which stores video game details.The table name is games &

  • 0

I have a database which stores video game details.The table name is games & its primary key is ‘gameNo’, which is alphanumeric(ex. G1,G2,G3…. etc.). I want to retrieve the last entered game’s number in order to generate the game number for the next game, when it is entered. When I use,

this.cmd = new OleDbCommand("SELECT MAX(gameNo) FROM games",this.con.conObj());

i get incorrect results. For example if there are gameNo values like G2 & G190, I want to retrieve G190, instead I get G2. Please any help would be greatly appreciated. I’m a student & if possible a good explanation would be a huge help too. Thanks in advance. By the way i’m using Visual C#.

  • 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-22T14:33:59+00:00Added an answer on May 22, 2026 at 2:33 pm

    This is a consequence of storing the key as a varchar column.

    I would separate out the ‘G’ from the Number and have two columns. If it is always ‘G’ then you dont even need the two columns.

    Also you have another problem which is caused by using the SELECT MAX(gameNo) FROM games to get the last game number. If this system is a multi user system then two users could get the same number. You didn’t mention which database you where using but all databases will let you safely get a unique id for a game.

    I would have a table something like (This is for SQL Server but you will get the idea.

    CREATE TABLE Games(
        GameID int IDENTITY(1,1),
        ...Other Columns,
        CONSTRAINT PK_Games PRIMARY KEY CLUSTERED(GameID))
    

    Then when you create the new row for the game the database will handle giving you a new GameID.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table A which stores records, A has a primary key
I have a table in my database which stores a tree structure. Here are
I have a database table called Posts which stores all the information regarding an
I have a database table which stores membership renewals each year. When insert the
I have an EMPLOYEE table in a SQL Server 2008 database which stores information
I have a database table transaction which stores all the transaction made by users
I have a table in my database which stores packing slips and their information.
I have a database table which stores a type for a project which stores
I have the below requirement: Front end for a big database which stores details
I have a database table which stores products. Each product can have multiple colours.

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.