Hello, I'm trying to update some records of a database table called "PETICIONS_TRESORERIA" with this structure: codi int data_peticio datetime name varchar (first two fields made the primary key) .. .. .. I'm using a data adapter with a UpdateCommand as follows: update PETICIONS_TRESORERIA set codi=@codi,data_peticio=@data_peticio,name=@name where codi=@codi and data_peticio=@data_peticio The "SourceVersion" property for the UpdateCommand parameters @codi and @data_peticio, are set to "DataRowVersion.Original", as if the user change them on the associated datagrid , I want to return the original values for changing them An example will be more clear: If I have these original values for codi, data_peticio and name : 1000,1/1/2007,Roger And I change the "name" to other value, when I do the data adapter update, it works perfect, but, if I change the code or data_peticio, nothing happens (no errors, no update). The same happens if I undo the definition of the primary key on the table. What's the problem ? Thanks in advance, Roger Tranchez
You are setting code to the original version in both cases. You need to use different parameters, one for codi in the SET clause, and one for codi in the WHERE clause. Same for data_peticio. The one in the WHERE clause should be DataRowVersionOriginal, the other one needs to be ModifiedCurrent. Robin S. --------------------------------------- [quoted text, click to view] "Roger Tranchez" <RogerTranchez@discussions.microsoft.com> wrote in message news:21B62709-128A-461C-ACDA-893ACD979F3C@microsoft.com... > Hello, > > I'm trying to update some records of a database table called > "PETICIONS_TRESORERIA" with this structure: > > codi int > data_peticio datetime > name varchar > > (first two fields made the primary key) > . > . > . > I'm using a data adapter with a UpdateCommand as follows: > > update PETICIONS_TRESORERIA set > codi=@codi,data_peticio=@data_peticio,name=@name where codi=@codi and > data_peticio=@data_peticio > > The "SourceVersion" property for the UpdateCommand parameters @codi and > @data_peticio, are set to "DataRowVersion.Original", as if the user > change > them on the associated datagrid , I want to return the original values > for > changing them > > An example will be more clear: > > If I have these original values for codi, data_peticio and name : > > 1000,1/1/2007,Roger > > And I change the "name" to other value, when I do the data adapter > update, > it works perfect, but, if I change the code or data_peticio, nothing > happens > (no errors, no update). > > The same happens if I undo the definition of the primary key on the > table. > > What's the problem ? > > > Thanks in advance, > > > Roger Tranchez > .NET 2005 and DB developer
Hi, THIS IS an absolute satisfactory answer ! thanks a lot... nothing like being a "crack" as you... thanks again. p.d.: I love managed newsgroups 8-D ; I hope someday I could help others as you so easily... -- Roger Tranchez ..NET 2005 and DB developer [quoted text, click to view] "RobinS" wrote: > You are setting code to the original version in both cases. You need to use > different parameters, one for codi in the SET clause, and one for codi in > the WHERE clause. Same for data_peticio. The one in the WHERE clause > should be DataRowVersionOriginal, the other one needs to be > ModifiedCurrent. > Robin S. > --------------------------------------- > "Roger Tranchez" <RogerTranchez@discussions.microsoft.com> wrote in message > news:21B62709-128A-461C-ACDA-893ACD979F3C@microsoft.com... > > Hello, > > > > I'm trying to update some records of a database table called > > "PETICIONS_TRESORERIA" with this structure: > > > > codi int > > data_peticio datetime > > name varchar > > > > (first two fields made the primary key) > > . > > . > > . > > I'm using a data adapter with a UpdateCommand as follows: > > > > update PETICIONS_TRESORERIA set > > codi=@codi,data_peticio=@data_peticio,name=@name where codi=@codi and > > data_peticio=@data_peticio > > > > The "SourceVersion" property for the UpdateCommand parameters @codi and > > @data_peticio, are set to "DataRowVersion.Original", as if the user > > change > > them on the associated datagrid , I want to return the original values > > for > > changing them > > > > An example will be more clear: > > > > If I have these original values for codi, data_peticio and name : > > > > 1000,1/1/2007,Roger > > > > And I change the "name" to other value, when I do the data adapter > > update, > > it works perfect, but, if I change the code or data_peticio, nothing > > happens > > (no errors, no update). > > > > The same happens if I undo the definition of the primary key on the > > table. > > > > What's the problem ? > > > > > > Thanks in advance, > > > > > > Roger Tranchez > > .NET 2005 and DB developer > >
Thanks, you're very kind. Everybody knows *something* they can share. :-) Robin S. ---------------------- [quoted text, click to view] "Roger Tranchez" <RogerTranchez@discussions.microsoft.com> wrote in message news:7FCC83C1-C7CF-453E-95EA-F564132C9ADA@microsoft.com... > Hi, > > THIS IS an absolute satisfactory answer ! thanks a lot... nothing like > being > a "crack" as you... thanks again. > > p.d.: I love managed newsgroups 8-D ; I hope someday I could help others > as > you so easily... > > -- > Roger Tranchez > .NET 2005 and DB developer > > > "RobinS" wrote: > >> You are setting code to the original version in both cases. You need to >> use >> different parameters, one for codi in the SET clause, and one for codi >> in >> the WHERE clause. Same for data_peticio. The one in the WHERE clause >> should be DataRowVersionOriginal, the other one needs to be >> ModifiedCurrent. >> Robin S. >> --------------------------------------- >> "Roger Tranchez" <RogerTranchez@discussions.microsoft.com> wrote in >> message >> news:21B62709-128A-461C-ACDA-893ACD979F3C@microsoft.com... >> > Hello, >> > >> > I'm trying to update some records of a database table called >> > "PETICIONS_TRESORERIA" with this structure: >> > >> > codi int >> > data_peticio datetime >> > name varchar >> > >> > (first two fields made the primary key) >> > . >> > . >> > . >> > I'm using a data adapter with a UpdateCommand as follows: >> > >> > update PETICIONS_TRESORERIA set >> > codi=@codi,data_peticio=@data_peticio,name=@name where codi=@codi and >> > data_peticio=@data_peticio >> > >> > The "SourceVersion" property for the UpdateCommand parameters @codi >> > and >> > @data_peticio, are set to "DataRowVersion.Original", as if the user >> > change >> > them on the associated datagrid , I want to return the original values >> > for >> > changing them >> > >> > An example will be more clear: >> > >> > If I have these original values for codi, data_peticio and name : >> > >> > 1000,1/1/2007,Roger >> > >> > And I change the "name" to other value, when I do the data adapter >> > update, >> > it works perfect, but, if I change the code or data_peticio, nothing >> > happens >> > (no errors, no update). >> > >> > The same happens if I undo the definition of the primary key on the >> > table. >> > >> > What's the problem ? >> > >> > >> > Thanks in advance, >> > >> > >> > Roger Tranchez >> > .NET 2005 and DB developer >> >> >>
Don't see what you're looking for? Try a search.
|