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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:40:35+00:00 2026-05-27T19:40:35+00:00

I’m using a datagridview to display the records of a database. I also have

  • 0

I’m using a datagridview to display the records of a database. I also have a form that collects new data to be added to the database too. What I want to know is if the primary key is generated automatically or not once the data is inserted in the database using dataAdapter-DataSets.

I have a method in a class that handles all the tables for the different datagridviews. The client method looks like this.

public void AddNewClient (Client client)
        {
            try
            {
                DataRow dr = dataSet.Tables["Clients"].NewRow ();
                dr[1] = client.firstName;
                dr[2] = client.lastName;
                dr[3] = client.MI;
                dr[4] = client.address;
                dr[5] = client.city;
                dr[6] = client.state;
                dr[7] = client.zipcode;
                dr[8] = client.homePhone;
                dr[9] = client.cellPhone;
                dr[10] = client.otherPhone;
                dr[11] = client.faxNumber;
                dr[12] = client.email;
                dataSet.Tables["Clients"].Rows.Add (dr);

                adapterClients.Update (dataSet, "Clients");
            }
            catch (Exception e) { throw e; }
        } 

The dataSet.Tables[“Clients”] is bind to the DataGridViewClients. When the new record displays in the DataGridViewClients there’s no ClientID value. However, when I restart the application and the DataGridViewClients is displayed I can see how a new value to ClientID has been assigned. So I wonder is this something that is done automatically by SQL server or ….? I mean I don’t really know. 🙂

  • 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-27T19:40:36+00:00Added an answer on May 27, 2026 at 7:40 pm

    The ClientID is probably an identity column. That means the database automatically assigns a new number to each row. Even if you wanted to, you would not be allowed to set the value of the identity column yourself.

    An identity column is often a primary key, but this is not always true. A primary key can be made up of any set of columns that uniquely identifies a row. It’s easy to see that an “auto-number” or identity column meets this requirement.

    You can list all identity columns in your database with the following query:

    select  t.name
    ,       c.name
    from    sys.tables t
    join    sys.columns c
    on      c.object_id = t.object_id
    where   c.is_identity = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.