Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Wed, 4 Jan 2006 05:23:02 -0800,    group: microsoft.public.dotnet.datatools        back       


Problem adding records with SQLDataadapter to SQL Server database   
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
date: Wed, 4 Jan 2006 05:23:02 -0800   author:   Rob Smeets

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us