Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0scope_identity help for adefwebserver.com tutscope_identity help for adefwebserver.com tut
Previous
 
Next
New Post
3/23/2007 4:20 AM
 
Greetings,

I followed Michael Washington's nice Guest Book module development tutorial and was wondering if someone could please offer some guidance on how to retrieve the scope_identity from the db when a guestbook entry is submitted. I thought I knew enough (or at least could stumble onto) how to send the int value back up the chain (from the SP to DAL, to BLL, then to the presentation layer) but I've had no luck for the last week.

The end of my SP looks like this:
select scope_identity() as 'gbID'
RETURN

The SqlDataProvider has:

Public Overrides Function YourCompany_GuestBook_Insert(ByVal ModuleId As Integer, ByVal Name As String, ByVal Email As String, ByVal Message As String) As Integer

Return CType(SqlHelper.ExecuteScalar(ConnectionString, GetFullyQualifiedName("YourCompany_GuestBook_Insert"), ModuleId, Name, Email, Message), Integer)

End Function

The DataProvider has:

Public MustOverride Function YourCompany_GuestBook_Insert(ByVal ModuleId As Integer, ByVal Name As String, ByVal Email As String, ByVal Message As String) As Integer


The Controller has:
<DataObjectMethod(DataObjectMethodType.Insert)> _
Public Shared Function GuestBook_Insert(ByVal objTest As GuestBookInfo) As Integer

Return CType(DataProvider.Instance.YourCompany_GuestBook_Insert(objTest.ModuleId, objTest.Name, objTest.Email, objTest.Message), Integer)

End Function

In the ViewGuestBook.ascx.vb I have:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not (Request.Params("gbID") Is Nothing) Then
... do something

Thanks in advance.

Ben Williams
 
New Post
3/25/2007 9:41 AM
 

I have also tried retrieving the scope_identity after working with the Super-Fast Super-Easy Module (DAL+) tutorial but no success there either.  I think at this point I have a hodge-podge of code... maybe I need to add an input parameter to the ObjectDataSource in the view ascx file?  Or add something in the Protected Sub InsertingItem(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertEventArgs) Handles FormView1.ItemInserting in the code behind?

 
New Post
3/25/2007 10:19 AM
 

I am only looking at this quickly so I may not be correct (It's 7 am in Los Angeles and I have been working on a DNN Tutorial all morning.. :)

The problem seems to be that since the ObjectDataSource control is calling the "GuestBook_Insert" method, the value is passed to the ObjectDataSource control. There is a "Inserted" event that is fired AFTER the ObjectDataSource Control does an Insert (in this case calling your "GuestBook_Insert" method). You should be able to wire-up a method to this event and retrieve the value.



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
3/26/2007 12:31 AM
 

Thanks for the heads-up about the OnInserted event. After a few hours of researching/testing
today I have discovered that one could use either

A. OnInserted="ObjectDataSource_ThingsForSale_Inserted" in the asp:ObjectDataSource in the .ascx file

along w/this in the code behind:

Protected Sub ObjectDataSource_Tasks_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs)

OR

B. omit OnInserted in the .ascx and just go with this in the code behind:

Protected Sub ObjectDataSource_Tasks_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs) Handles ObjectDataSource_Tasks.Inserted

What happened was that I was finally able to get the scope_identity returned to a response.write action but it was being fired twice.  The ultimate goal is to auto-email the transaction id per se, but we don't need an email event firing twice for each submission, no way! 

So, did some poking around and found this post - GridView DeleteCommand Firing Twice - which helped clue me in that I don't need to use OnInserted="ObjectDataSource_ThingsForSale_Inserted" and 'Handles ObjectDataSource_Tasks.Inserted' at the same time.

Thanks again!

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0scope_identity help for adefwebserver.com tutscope_identity help for adefwebserver.com tut


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out