PC Review


Reply
Thread Tools Rate Thread

Data adapter.Update with fields that are part of the update condit

 
 
=?Utf-8?B?Um9nZXIgVHJhbmNoZXo=?=
Guest
Posts: n/a
 
      27th Feb 2007
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
 
Reply With Quote
 
 
 
 
RobinS
Guest
Posts: n/a
 
      27th Feb 2007
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" <(E-Mail Removed)> wrote in message
news:21B62709-128A-461C-ACDA-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?Um9nZXIgVHJhbmNoZXo=?=
Guest
Posts: n/a
 
      27th Feb 2007
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" <(E-Mail Removed)> wrote in message
> news:21B62709-128A-461C-ACDA-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
RobinS
Guest
Posts: n/a
 
      27th Feb 2007
Thanks, you're very kind. Everybody knows *something* they can share. :-)

Robin S.
----------------------
"Roger Tranchez" <(E-Mail Removed)> wrote in message
news:7FCC83C1-C7CF-453E-95EA-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in
>> message
>> news:21B62709-128A-461C-ACDA-(E-Mail Removed)...
>> > 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

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Adapter update =?Utf-8?B?U2NvdHQ=?= Microsoft ADO .NET 2 23rd Sep 2005 07:47 AM
Data Adapter update !!bogus Microsoft ASP .NET 1 12th Apr 2005 08:58 AM
Update with SQL Data Adapter Matt Tapia Microsoft ADO .NET 5 24th Jul 2004 04:18 AM
Data Adapter Update Ruslan Shlain Microsoft ADO .NET 2 6th Feb 2004 09:13 PM
data adapter update Adam Microsoft Dot NET 1 31st Jul 2003 04:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:52 PM.