locked
error in photoalbum_list.aspx RRS feed

  • Question

  • User493558242 posted

    Hi,
    I am a beginner level asp.net coder. I had came across an error and couldn't find a way out. I searched the forum but i couldn't find any topic related to this problem...

    I have downloaded the club starter kit and created a new web application by choosing the template from vs2005.
    I hit F5 and started to browse pages.
    When i click the "photos" section i got the error : "Object cannot be cast from DBNull to other types. "

    the erroneous code was:

    protected void SqlDataSource1_Selected(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
    {
       int pages;
       pages =
    Convert.ToInt32(e.Command.Parameters["@pageCount"].Value);
       
    pn1.Count = pages;
       pn2.Count = pages;
    }

    This is a fresh install of club starter kit, i am pretty sure that i didn't do anything wrong.
    What may be the problem?

    Thanks in advance...

    When i click the "photos" section i g

    Monday, July 3, 2006 2:46 PM

All replies

  • User493558242 posted

    I have discovered the cause of the problem.
    It was in stored procedure : PagedAlbumList.

    The parameter name was incorrect:

    ALTER PROCEDURE [dbo].[PagedAlbumList]
    (
    @ownerID UNIQUEIDENTIFIER,
    @pageNum INT = 1,
    @pageSize INT = 10
    )

    @ownerID should be @ownerid.

    You may ask "what is the difference between 'id' and 'ID'".

    The answer is the letter "i" is not equal to capital "I" in Turkish.
    My instance of sql express is configured to use turkish collation.

    this post may be transfered to bugs and solutions...

    Monday, July 3, 2006 5:09 PM
  • User493558242 posted

    Similar errors are everywhere! Just found another mistyped "I" in App_Code/ImageHandling.cs line 20.
    The code was:
    SqlCommand command = new SqlCommand("INSERT INTO Images (title, origimage, largeimage, thumbimage, album) VALUES ( @title, @origimage, @largeimage, @thumbimage, @albumid); select SCOPE_IDENTITY()", connection);

    And should be:
    SqlCommand command = new SqlCommand("INSERT INTO images (title, origimage, largeimage, thumbimage, album) VALUES ( @title, @origimage, @largeimage, @thumbimage, @albumid); select SCOPE_IDENTITY()", connection);

    I should debug whole application and hunt for mistyped "i"s and "I"s.

    Tuesday, July 4, 2006 4:42 AM