Problem adding records with SQLDataadapter to SQL Server database

G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top