Re: Problem adding records with SQLDataadapter to SQL Server database



Hi Rob,

First thing to do is to use negative values for both seed and increment.
So the new records won't interfere with old ones.
As per duplicates, this is (annoyingly) correc: see if this helps you
http://support.microsoft.com/kb/313540/en-us

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Rob Smeets" <RobSmeets@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7826CD22-63BC-4BDD-A864-C5D1C22217CC@xxxxxxxxxxxxxxxx
> Hi,
>
> I'm building an application, to edit data on a SQL Server database.
> Database has a table Jobs with primary key (JobID) with identity seed = 1
> and identity increment = 1
>
> I'm using SQLConnection and SqlDataAdapters, DataSet, datagrid and
> DataViews
> Dataset represents the SQL database.
>
> When i add a record to the DataSet(Jobs), there is a Primary key
> generated.
> So for example the datagrid on my form shows the following:
>
>
> JobID JobName JobDescription
> 1 test1 This is the first job record
> 2 test2 This is the second job record
> 3 test3 This is the third job record
>
>
> When i click add i add a new record to the dataset.
> The primairy key is generated (not by my code) as JobID = 4.
> But my JobID on SQL server (because i've added several records and deleted
> them) is 15. When i click save my SQLDataAdapter is updating the SQL
> server
> and adds the record (through stored procedures) without supplying a
> JOBID.
> When the save is done i have 2 extra records. One is a record wich only
> exists in the dataset with JobID = 4 and one new record from the SQL
> server
> with JobID = 15
>
> This is not expected behaivior... Anyone have some ideas?
>
> Help would be greatly appriciated, thanks in advance
>
> Rob Smeets


.



Relevant Pages

  • Re: Access 2007->SQL Server2005 "connection was forcibly closed",G
    ... I moved every table I was able to move to the SQL ... closed connections - but all of these errors are in the version which used ... the SQL Server 2000 and everything worked ... communication between ODBC (OLEDB and Native Client, ...
    (microsoft.public.sqlserver.connect)
  • Re: Unable to Apply SP4 to SQL 2000 Cluster (new Node)
    ... Rebuild the node in the failover cluster. ... Scenario 1" in SQL Server 2000 Books Online. ... This setup process updates to SP4 only the binaries on the new ...
    (microsoft.public.sqlserver.clustering)
  • Re: WSS 3.0 question
    ... I followed the advise given in removing WSS 3.0 etc, ... the server is complaining that the SQL service(?) was tempered with or corrupt. ... I may just instal the SQL server as I was going eventuall use it anyway. ... If WSUS 3.0 is installed, I would suggest you uninstall it and then you install WSS 3.0. ...
    (microsoft.public.windows.server.sbs)
  • Re: WSUS
    ... I'm not seeing performance issues with the full enchilada installed, and 25 users busy hitting SQL. ... WSUS isn't difficult to uninstall - if you have WSUS v2 (installed with SBS R2) uninstall R2 from add/remove programs. ... How can anyone work with 4 instances of SQL Server on the same box? ...
    (microsoft.public.windows.server.sbs)
  • Re: SQL Resets
    ... If it were SQL that was falling short, ... The default backlog for SQL Server is 5. ... System.InvalidOperationException: Internal connection fatal error. ... From time to time, under heavy loads, we are getting resets at ...
    (microsoft.public.sqlserver.connect)