Hi

I have asked this question before but have not received any clear answer. I
have a winform app with bound controls via dataadapter/dataset combination.I
have a dbconcurrency exception ex. Now I have the following;

DataRow = ex.Row
DataTable = ex.Row.Table
DataColumns = ex.Row.Table.Columns
DataSet = ex.row.Table.Dataset

How can I now via code, do the following;

1. Make a copy of the datarow,

2. Re-read the row from datasource,

3. Update read row with values form row copy.

Any help woudl be appreciated.

Many Thanks

Regards

Re: Concurrency error handling by Cor

Cor
Sun Jul 20 02:07:27 CDT 2008

John,

All your three questions are impossible to do.

>
> 1. Make a copy of the datarow,
>
A datarow is a collection of objects that exist partially in the datarow
itself as item collection and partially in the datatable columns collection.

> 2. Re-read the row from datasource,
>
You never need to re-read the row from a datasource as you haven't
overwritten it.


> 3. Update read row with values form row copy.
>
As long as you don't reset your concurrency protection, you would not be
able to overwrite it with whatever you want, but if you want to do that, you
simple use the original row and disable the concurrency checking.

Cor


Re: Concurrency error handling by John

John
Sun Jul 20 08:09:02 CDT 2008

Hi Cor

Thanks, How can I disable concurrency checking?

Thanks

Regards

"Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
news:ucUyCdj6IHA.4468@TK2MSFTNGP02.phx.gbl...
> John,
>
> All your three questions are impossible to do.
>
>>
>> 1. Make a copy of the datarow,
>>
> A datarow is a collection of objects that exist partially in the datarow
> itself as item collection and partially in the datatable columns
> collection.
>
>> 2. Re-read the row from datasource,
>>
> You never need to re-read the row from a datasource as you haven't
> overwritten it.
>
>
>> 3. Update read row with values form row copy.
>>
> As long as you don't reset your concurrency protection, you would not be
> able to overwrite it with whatever you want, but if you want to do that,
> you simple use the original row and disable the concurrency checking.
>
> Cor



Re: Concurrency error handling by Cor

Cor
Tue Jul 22 06:01:02 CDT 2008

Hi John,

I thought that I had answered you, however I don't see my answer

:-)

Have a look at the SQL code for the update in your program or stored
procedures where is written something as.

Select TimeStamp from Table

If TimeStamp = @TimeStamp
Begin and then the update transaction in SQL .

As you delete that part, then the SQL code will probably eat everything you
deliver to it.

(It can also be a range of old values, compared with the new selected
existing values)

(It is probably easier to write the Update SQL yourself new by hand and than
skip the Select of the current values or current tinestamp)

Cor


"John" <info@nospam.infovis.co.uk> schreef in bericht
news:u0g1Enm6IHA.1468@TK2MSFTNGP05.phx.gbl...
> Hi Cor
>
> Thanks, How can I disable concurrency checking?
>
> Thanks
>
> Regards
>
> "Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
> news:ucUyCdj6IHA.4468@TK2MSFTNGP02.phx.gbl...
>> John,
>>
>> All your three questions are impossible to do.
>>
>>>
>>> 1. Make a copy of the datarow,
>>>
>> A datarow is a collection of objects that exist partially in the datarow
>> itself as item collection and partially in the datatable columns
>> collection.
>>
>>> 2. Re-read the row from datasource,
>>>
>> You never need to re-read the row from a datasource as you haven't
>> overwritten it.
>>
>>
>>> 3. Update read row with values form row copy.
>>>
>> As long as you don't reset your concurrency protection, you would not be
>> able to overwrite it with whatever you want, but if you want to do that,
>> you simple use the original row and disable the concurrency checking.
>>
>> Cor
>
>


Re: Concurrency error handling by John

John
Fri Jul 25 19:44:23 CDT 2008

Hi Cor

I have the below Update SP (slightly simplified to exclude irrelevant
columns);

UPDATE [dbo].[Clients] SET [Company] = @Company, [Address 1] = @Address_1
WHERE (([ID] = @Original_ID) AND ([SSMA_TimeStamp] =
@Original_SSMA_TimeStamp));
SELECT ID, Company, [Address 1] SSMA_TimeStamp FROM Clients WHERE (ID = @ID)

Ideally on concurrency violation I would like to give user option to force
save or cancel save. What would be the mechanism for that? My applications
is a vb.net winform app.

Many Thanks

Regards

"Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
news:0D340C13-B1FA-44DD-A3F4-C57AE1FDA344@microsoft.com...
> Hi John,
>
> I thought that I had answered you, however I don't see my answer
>
> :-)
>
> Have a look at the SQL code for the update in your program or stored
> procedures where is written something as.
>
> Select TimeStamp from Table
>
> If TimeStamp = @TimeStamp
> Begin and then the update transaction in SQL .
>
> As you delete that part, then the SQL code will probably eat everything
> you
> deliver to it.
>
> (It can also be a range of old values, compared with the new selected
> existing values)
>
> (It is probably easier to write the Update SQL yourself new by hand and
> than
> skip the Select of the current values or current tinestamp)
>
> Cor
>
>
> "John" <info@nospam.infovis.co.uk> schreef in bericht
> news:u0g1Enm6IHA.1468@TK2MSFTNGP05.phx.gbl...
>> Hi Cor
>>
>> Thanks, How can I disable concurrency checking?
>>
>> Thanks
>>
>> Regards
>>
>> "Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
>> news:ucUyCdj6IHA.4468@TK2MSFTNGP02.phx.gbl...
>>> John,
>>>
>>> All your three questions are impossible to do.
>>>
>>>>
>>>> 1. Make a copy of the datarow,
>>>>
>>> A datarow is a collection of objects that exist partially in the datarow
>>> itself as item collection and partially in the datatable columns
>>> collection.
>>>
>>>> 2. Re-read the row from datasource,
>>>>
>>> You never need to re-read the row from a datasource as you haven't
>>> overwritten it.
>>>
>>>
>>>> 3. Update read row with values form row copy.
>>>>
>>> As long as you don't reset your concurrency protection, you would not be
>>> able to overwrite it with whatever you want, but if you want to do that,
>>> you simple use the original row and disable the concurrency checking.
>>>
>>> Cor
>>
>>
>



Re: Concurrency error handling by Cor

Cor
Sat Jul 26 05:17:41 CDT 2008

John,

Then create an extra Update where that WHERE clause part from the timestamp
from the one you show now is deleted.

I can not tell you how to do it in VB as I don't know what you use to update
in that, it can be an execute nonquery or a xxAdapter. Those you have of
course to make new, or simple set the right update sql to its command every
time you use the original or the overwritting one.


However be aware what you doing, as this can give big errors.
(There is a sample in banking busines where this was used to fraud).

Cor

"John" <info@nospam.infovis.co.uk> schreef in bericht
news:u5du9ir7IHA.616@TK2MSFTNGP02.phx.gbl...
> Hi Cor
>
> I have the below Update SP (slightly simplified to exclude irrelevant
> columns);
>
> UPDATE [dbo].[Clients] SET [Company] = @Company, [Address 1] = @Address_1
> WHERE (([ID] = @Original_ID) AND ([SSMA_TimeStamp] =
> @Original_SSMA_TimeStamp));
> SELECT ID, Company, [Address 1] SSMA_TimeStamp FROM Clients WHERE (ID =
> @ID)
>
> Ideally on concurrency violation I would like to give user option to force
> save or cancel save. What would be the mechanism for that? My applications
> is a vb.net winform app.
>
> Many Thanks
>
> Regards
>
> "Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
> news:0D340C13-B1FA-44DD-A3F4-C57AE1FDA344@microsoft.com...
>> Hi John,
>>
>> I thought that I had answered you, however I don't see my answer
>>
>> :-)
>>
>> Have a look at the SQL code for the update in your program or stored
>> procedures where is written something as.
>>
>> Select TimeStamp from Table
>>
>> If TimeStamp = @TimeStamp
>> Begin and then the update transaction in SQL .
>>
>> As you delete that part, then the SQL code will probably eat everything
>> you
>> deliver to it.
>>
>> (It can also be a range of old values, compared with the new selected
>> existing values)
>>
>> (It is probably easier to write the Update SQL yourself new by hand and
>> than
>> skip the Select of the current values or current tinestamp)
>>
>> Cor
>>
>>
>> "John" <info@nospam.infovis.co.uk> schreef in bericht
>> news:u0g1Enm6IHA.1468@TK2MSFTNGP05.phx.gbl...
>>> Hi Cor
>>>
>>> Thanks, How can I disable concurrency checking?
>>>
>>> Thanks
>>>
>>> Regards
>>>
>>> "Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
>>> news:ucUyCdj6IHA.4468@TK2MSFTNGP02.phx.gbl...
>>>> John,
>>>>
>>>> All your three questions are impossible to do.
>>>>
>>>>>
>>>>> 1. Make a copy of the datarow,
>>>>>
>>>> A datarow is a collection of objects that exist partially in the
>>>> datarow itself as item collection and partially in the datatable
>>>> columns collection.
>>>>
>>>>> 2. Re-read the row from datasource,
>>>>>
>>>> You never need to re-read the row from a datasource as you haven't
>>>> overwritten it.
>>>>
>>>>
>>>>> 3. Update read row with values form row copy.
>>>>>
>>>> As long as you don't reset your concurrency protection, you would not
>>>> be able to overwrite it with whatever you want, but if you want to do
>>>> that, you simple use the original row and disable the concurrency
>>>> checking.
>>>>
>>>> Cor
>>>
>>>
>>
>
>