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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:21:48+00:00 2026-05-30T12:21:48+00:00

I have a SQL Server Database with several tables. One of them has ID

  • 0

I have a SQL Server Database with several tables. One of them has “ID” (primary key), “Name” and other columns that i won’t mention here for sake of simplicity. “ID” column is auto increment, unique and when i add some row using “SQL Server management studio”, “ID” column increments properly. Database is old and current auto increment is at 1244 or so.

Now, i have created a C# project that uses TYPED Dataset to work with data from database. My database starts empty, dataset is filled using table adapters, new rows are added using my program but there’s a problem i have never stumbled upon so far: when my program adds new row to Dataset, then updates database (using table adapter), “ID” column in my database gets correct auto-incremented number (1245,1246 etc), BUT my “ID” column in dataset gets “-1”, “-2” instead! What’s the problem? How can i tell my dataset to use auto-increment seed specified by database instead generating it’s own NEGATIVE (???) primary key numbers?

EDIT:
I get and compare rows using this:

dsNames.tbNamesRow[] TMP = basedataset.tbNames.Select() as dsNames.tbNamesRow[];
foreach (dsNames.tbNamesRow row in TMP)
{
    string Name = row.Name;
    bool Found = Name == Search;
    if (CompareDelegate != null)
        Found = CompareDelegate(Name, Search);
    if (Found)
    {
        int ID = row.ID;
        break;
    }
}
  • 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-30T12:21:49+00:00Added an answer on May 30, 2026 at 12:21 pm

    My original comment was kind of incorrect, I assumed you were retrieving the value from the database and THAT dataset had incorrect values in it.

    The way ADO.NET deals with preventing collisions with it’s disconnected dataset, it assigns negative IDENTITY column values, because it wouldn’t know a possible positive number that IS NOT a collision as it’s disconnected. These (negative) values are unique in terms of that transaction.

    When you try and commit your changes, the ADO.NET engine determines the proper SQL to produce the correct result.

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

Sidebar

Related Questions

I have a SQL Server 2005 database with several tables. One of the tables
I have a SQL database that has several hundred tables in it, but I
I'm helping implement a SQL Server 2008 database and I have several columns that
I have SQL Server 2008 database with 2 tables: Table A has columns ID
In my SQL Server 2008 Enterprise I have a database that contains several tables:
I have the requirement to search several different tables in my SQL Server database.
I have a SQL Server that houses Several Databases. I have a Main Database
I have an application that uses a SQL Server database with several instances of
We have several SQL Server 2000 databases (I know, we need to upgrade) that
I have an SQL server database that I am querying and I only want

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.