Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Quick login...


Or... now make it easy with Facebook Integration
Connect via Facebook



Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

Possible to update DB *AND* select in same sp on Initial Bind
Last Post 01-18-2010 08:54 AM by Todd Janes. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Todd JanesUser is Offline
wading in the water
wading in the water
Posts:17
Avatar

--
01-15-2010 06:41 AM

     I have a form that nurses will use to enter details of calls that they receive. Following the initial submission of this form, other nurses can see it in a call queue using Reports module and select it to update (using the method from Dynamic Forms demonstration #14). I would like to be able to show nurses in the Reports module that the call details Dynamic Form is being viewed/edited by another nurse so as to avoid race conditions. When a nurse clicks on the call in the queue and it is opened for edit, this is accomplished by a select statement in the Initial SQL Rendering/Bind event that pulls the data into the form. At the same time I would like to be able to update a field in the table that flags the record. The field would then display in the Reports module at next refresh and show that someone is editing.

    I have tried adding the update and select statements to the initial bind field, but when I do neither gets executed, so the field in the DB is not updated and the data is not pulled into the form. I have tried putting in a stored procedure and executing from the initial bind, but I get the same results. I know that SPs can only have one result set in most situations, but since the update doesn't return anything, I'm not sure why I can't get that to work.

    If anyone knows how I can make this work, either by tweaking what I'm already doing, or by supplying another method to accomplish both things, I'd really appreciate it. I can supply any information you need, but I figured I'd wait to add anything else until it is asked for since I'm not sure what will be helpful.

    Thanks -ToddJ

    Richard BaileyUser is Offline
    going with the flow
    going with the flow
    Posts:66
    Avatar

    --
    01-15-2010 09:51 PM

    It should work on SQL Bind.  The biggest problem would be if someone opens the record for edit and doesn't close the form - you mind need to do some pretty tricky coding  -  such a scheduled job or something to check if a session is still active, and if the session isn't still active but the record is still locked by the session, then to unlock records being edited by that session.  Or maybe allow records to be locked on a per-user bases, so the user can start editing - which locks the record - but then can't edit other records until they save and unlock their open locks.  Does that make sense?

    Assume your SQL Bind is for Update only (e.g. SQLType = Update, like the demonstrations)

    Have SQL Bind call a stored procedure that retrieves the record for update -  the same stored procedure could simply flag either a field in that record or a relational table to lock that stored procedure from being opened.

    Then just make sure that your Form Completion event releases the flag....

     

    sp_sqlbind1 'record_id', 'dnn_userid'      e.g. sp_sqlbind1 '$(DSParam1)', '$(DNN_UID)'

    And in the stored procedure (I wrote this in the fckeditor, so it may not be 100% acurate, was just writting it as an example):

    create procedure sp_sqlbind1 (@record_id int, @dnn_userid int)

    AS

    BEGIN

    declare @flag_status int, @user_locks int

    select @user_locks = count(*) from tb_status where dnn_userid = @dnn_userid

    if @user_locks = 1

    BEGIN

    select 'your notice to the user they have a record locked' as html_label1, '-- the field [user_has_locked_records] could correspond to a question event on the data springs form to disable submit - or even disable every field on the form except for the labels with links to the locked record.

    RETURN

    END

     

    if @user_locks = 0

    BEGIN

    -- then get the current status of the current record being requested

    select @flag_status = flag_status from tb_status where record_id = @record_id

    -- status of 1 = actively being edited and cannot be edited

    -- status of 0 = not being edited

    if @flag_status = 0  -- not being edited, so we update the status that the record is going in to edit mode

    BEGIN

     

    update tb_status set flag_status = 1 where record_id = @record_id

    -- Then your query to populate the form for edit, us the [flag_status] to correspond to a question with a question even that enables the fields or shows the Submit button or whatever that would allow the record to be edited and saved.

    select 'no other records locked by you' as html_label1, field1, field2, field3, field4, @flag_status as [flag_status] from tb_mydatatable where record_id = @record_id

    END

    if @flag_status = 1  -- being edited,

    BEGIN

    select 'this record is locked' as html_label1, field1, field2, field3, field4, @flag_status as [flag_status] from tb_mydatatable where record_id = @record_id

    -- and the above [flag_status] should then be used to disable the submit button or disable the fields so they can't be edited or whatever.

    END

     

     

    END

    END

     

     

    Todd JanesUser is Offline
    wading in the water
    wading in the water
    Posts:17
    Avatar

    --
    01-18-2010 08:54 AM
    Thanks, Richard! I didn't need to *really* lock the record at the DB level, so I ended up using a form of your solution that sets an Edit field on th erecord in the database to 'Y', then setting that back to 'N' on Submit. I then set up the reports (views) of the call queue to only enable the ilnk on the pencil icon when Edit <> 'Y'. I also made it change the edit pencil color to red. I added a third view for the call queue that still has the links enables, so if someone closes the browser or otherwise does not click Submit before leaving the webform, someone can go into this view, select the record for editing, then click Submit to release the form.

    My main question that I was asking, though, was how to do an update and a select on the initial bind. It had been a while since I had written or used a stored proc, so I forgot that the syntax was my_sp 'parameter', and was instead using my_sp('parameter'). D'Oh! This wasn't working, of course, and there was no message indicating that the SP was failing because of incorrect syntax. My third time looking at it I finally saw what was wrong.

    Thanks again! -ToddJ
    You are not authorized to post a reply.


     
     

    Join our mailing list...

    Get current news and events the easy way
    Subscribe Me

    Recent Blogs...

     
    Copyright 2005 - 2011 by Data Springs, Inc.
     
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi