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.0a problem: SqlHelper.ExecuteScalar keeps returning ScopeIdentity() as nulla problem: SqlHelper.ExecuteScalar keeps returning ScopeIdentity() as null
Previous
 
Next
New Post
7/18/2006 5:40 PM
 
I have absolutely no idea why this happens. I am calling the SqlHelper.ExecuteScalar with the proper parameters (the sproc works and the record is being added) and it returns null. This is the invocation:



public override int Articles_Add(ArticlesInfo articlesinfo_toAdd, int portalId)
        {
            try
            {
                return (int)SqlHelper.ExecuteScalar(ConnectionString,
                    GetFullyQualifiedName("MareNectaris_Articles_AddArticle"),
                    articlesinfo_toAdd.ModuleId, portalId, articlesinfo_toAdd.CategoryId,
                    articlesinfo_toAdd.AuthorId, articlesinfo_toAdd.CreatedByUserId,
                    articlesinfo_toAdd.EditorId, articlesinfo_toAdd.DateCreated,
                    articlesinfo_toAdd.DateLastModified, articlesinfo_toAdd.DateStart,           
                    articlesinfo_toAdd.DateEnd, articlesinfo_toAdd.DatePriorityEnd,
                    articlesinfo_toAdd.CreatedByUserName, articlesinfo_toAdd.AuthorName,
                    articlesinfo_toAdd.EditorName, articlesinfo_toAdd.EditorAddnotations,
                    articlesinfo_toAdd.Title, articlesinfo_toAdd.Lead, articlesinfo_toAdd.FullText,
                    articlesinfo_toAdd.KeyWords, articlesinfo_toAdd.IsApproved);
            }
            catch (Exception exc)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(exc);
                return -1;
            }
        }




------------------------------
this keeps crashing due to the reference not set exception. The sproc code (checked it in the query analizer, it works) code is here:





CREATE PROCEDURE MareNectaris_Articles_AddArticle
        @ModuleId int, @portalId int, @CategoryId int, @AuthorId int,
        @CreatedByUserId int, @EditorId int, @DateCreated datetime,
        @DateLastModified datetime, @DateStart datetime, @DateEnd datetime,
        @DatePriorityEnd datetime, @CreatedByUserName nvarchar (500), @AuthorName nvarchar (500),
        @EditorName nvarchar (500), @EditorAddnotations nvarchar, @Title nvarchar (500),
        @Lead nvarchar (1024), @FullText ntext, @KeyWords nvarchar (400),
        @IsApproved bit
AS
BEGIN

    SET NOCOUNT ON;
   

    INSERT INTO MareNectaris_Articles
    (
        ModuleId, portalId, CategoryId, AuthorId,
        CreatedByUserId, EditorId, DateCreated,
        DateLastModified, DateStart, DateEnd,
        DatePriorityEnd, CreatedByUserName, AuthorName,
        EditorName, EditorAddnotations, Title,
        Lead, [FullText], KeyWords,
        IsApproved
    ) VALUES
    (
        @ModuleId, @portalId, @CategoryId, @AuthorId,
        @CreatedByUserId, @EditorId, @DateCreated,
        @DateLastModified, @DateStart, @DateEnd,
        @DatePriorityEnd, @CreatedByUserName, @AuthorName,
        @EditorName, @EditorAddnotations, @Title,
        @Lead, @FullText, @KeyWords,
        @IsApproved
    )
   
    return Scope_Identity()

END


------------------------------
Is this behaviour of the ExecuteScalar something that anyone else has run into?
 
New Post
7/18/2006 6:05 PM
 
It seems I've solved the problem myself - with a little help of a cup of tea :)

The problem was return ScopeIdentity(). For some reason (beats me why really) ExecuteScalar can't read return. After changing return to select it started working fine. Sorry for wasting your time.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0a problem: SqlHelper.ExecuteScalar keeps returning ScopeIdentity() as nulla problem: SqlHelper.ExecuteScalar keeps returning ScopeIdentity() as null


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