Showing posts with label display. Show all posts
Showing posts with label display. Show all posts

Friday, March 30, 2012

how can i reserve a record to prevent anyone else from editing for X minutes?

Hey All,

I think this is something like locking, but not quite. I need to select a record in a database and display the information to the end user. The end user has a few minutes to review it before giving the ok at which point I will update the record.

However, while the user is reviewing the record, i dont want anyone else to be able to grab that record. I also want to make sure that if the user doesnt submit the page, that the record will be freed up and not indefinitely marked as taken.

What would be the best way to do this? This is with .net 2.0 and sql2000

I am afraid you want to prevent the following problem:

User A retrieves a record and it takes a long time before he submit and during that time User B updated that record so when user submit he will overwrite the record.

You can solve this problem by using the following way:

When a user submits a record you check the database to see if it has been updated by other users if so stop updating, display the updated record and ask him to try again.

Hope it helps.

|||

Thats not really an ideal solution since it means the user may fill out all their info, hit submit and then find out everything they submitted is now invalid.

However, i got some advice from the aspadvice.com ,mailing lists which seem like a good idea. I can add a date field to the table called LastLocked - and when i do my select, i only grab records where the lock is older then X minutes. I can also add a field LockedBy so that the user can access their own locked records. I think this will work for me.


thanks

Monday, March 12, 2012

How can I keep only the first 3 digits after decimal with no rounding?

I have a query with a field that returns a decimal number in it, such
as 56.995501432. I would like to display only up to the first 3
digits after the decimal point, like so: 56.995.
I have tried using the FORMAT and FORMATNUMBER functions within the
field expression using a mask of "###,###.000", but both of these want
to round the fourth decimal up, so that the end result is, 56.996
which is not correct for our needs. Why on earth do the format
functions implement rounding!' Is there a way to turn this off? Is
there something like a TRUNCATE function that allows me to specify how
many decimals to keep?
Please help! I'm stuckTry this in the control (not the query) that is displaying the data:
=Left(Fields!Fieldname.Value,Instr(Fields!FieldName.Value,".")-1) + "." +
Mid(Fields!FieldName.Value,Instr(Fields!FieldName.Value)+1,3)
Where
1.Left(Fields!Fieldname.Value,Instr(Fields!FieldName.Value,".")-1) finds
the everything before the decimal
2. Mid(Fields!FieldName.Value,Instr(Fields!FieldName.Value)+1,3) finds 3
digits after the decimal.
Hope this helps!
Michael
"Jerry H." wrote:
> I have a query with a field that returns a decimal number in it, such
> as 56.995501432. I would like to display only up to the first 3
> digits after the decimal point, like so: 56.995.
> I have tried using the FORMAT and FORMATNUMBER functions within the
> field expression using a mask of "###,###.000", but both of these want
> to round the fourth decimal up, so that the end result is, 56.996
> which is not correct for our needs. Why on earth do the format
> functions implement rounding!' Is there a way to turn this off? Is
> there something like a TRUNCATE function that allows me to specify how
> many decimals to keep?
> Please help! I'm stuck
>|||"Michael C" wrote:
> Try this in the control (not the query) that is displaying the data:
> =Left(Fields!Fieldname.Value,Instr(Fields!FieldName.Value,".")-1) + "." +
> Mid(Fields!FieldName.Value,Instr(Fields!FieldName.Value)+1,3)
> Where
> 1.Left(Fields!Fieldname.Value,Instr(Fields!FieldName.Value,".")-1) finds
> the everything before the decimal
> 2. Mid(Fields!FieldName.Value,Instr(Fields!FieldName.Value)+1,3) finds 3
> digits after the decimal.
> Hope this helps!
> Michael
> "Jerry H." wrote:
> > I have a query with a field that returns a decimal number in it, such
> > as 56.995501432. I would like to display only up to the first 3
> > digits after the decimal point, like so: 56.995.
> >
> > I have tried using the FORMAT and FORMATNUMBER functions within the
> > field expression using a mask of "###,###.000", but both of these want
> > to round the fourth decimal up, so that the end result is, 56.996
> > which is not correct for our needs. Why on earth do the format
> > functions implement rounding!' Is there a way to turn this off? Is
> > there something like a TRUNCATE function that allows me to specify how
> > many decimals to keep?
> >
> > Please help! I'm stuck
> >
> >
or) in the properties of the field, in format type : N3
or) use the round function round(field!...,3)
if you don't want rounding ?
=cint(field!...*1000)/1000
hope this helps