Groups | Blog | Home
all groups > dotnet windows forms databinding > april 2007 >

dotnet windows forms databinding : handle rounding at the database


jarm jarm
4/30/2007 11:59:21 AM
..Net v1.1 (& im using BDP adonet provider)

The problem:
Im using NUMBER types on an Oracle database. In .Net/C# designer I generate dataadapters and datasets. The designer does pick up the precision and scale correctly and sets the parameters up for the commands. I am using giant WHERE clause style concurrency checking, where every local value is tested against every value on the server in a WHERE clause to detect any change. My numbers are bound to textboxes.

There are two problems.
FIRST the textboxes allow input of any amount of decimal places without regard to precision or scale. I guess I'll have to restrict this myself by doing something in the validating event??

SECOND when the user enters something like 8.5434 that the database is going to round to and store as 8.54, I get a concurrency exception. Because the client code is expecting to see 8.5434 stored on the server. I guess if I fix problem 1, this will go away. But I would have thought the parameter setup would have rounded the number correctly when it forms the sql..?

thanks
---
Jim Rand
4/30/2007 3:52:28 PM
Do you have timestamps available for concurrency checking - much simpler?

UPDATE [AgencyNET].[UrlType] SET [UrlType] = @UrlType, [LastUpdated] =
getutcdate(), [LastUpdatedBy] = @LastUpdatedBy WHERE (([UrlTypeID] =
@Original_UrlTypeID) AND (CAST(TS AS INT) = @Original_TS));SELECT CAST(TS AS
INT) AS TS FROM AgencyNET.UrlType WHERE (UrlTypeID = @UrlTypeID)

[quoted text, click to view]

AddThis Social Bookmark Button