locked
Photo Album woes.. RRS feed

  • Question

  • User1683925724 posted

    Hi all,

    I've hit a snag that I can't seem to find the solution for - maybe one of you has come across this before and can help me out?

    I've moved my Personal Web Site from SQLExpress into SQL 2005, and the tables look like they are set up correctly - the primary keys are there, as are the table structures etc, but I now get this error if I try and create a new album:

     

    Cannot insert the value NULL into column 'AlbumID', table 'Personal.dbo.Albums'; column does not allow nulls. INSERT fails.
    The statement has been terminated.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'AlbumID', table 'Personal.dbo.Albums'; column does not allow nulls. INSERT fails.
    The statement has been terminated.

    Source Error:

     

    Line 161:				command.Parameters.Add(New SqlParameter("@IsPublic", IsPublic))
    Line 162: connection.Open()
    Line 163: command.ExecuteNonQuery()
    Line 164: End Using
    Line 165: End Using

     
    This used to work before, but now doesn't - from what I can gather from this it seems to be trying to create an album with an ID of null, instead of the next sequential number in the list of Album ID's?

    What's the best way of getting around this?

    Incidentally I created an album manually (through SQL manager etc) to test this, et voila it works, but then when you try and load a photo into it the same error occurs, as Photo ID it's trying is null too.

    Any idea why it's trying a null insert now where it wasn't before?

     
    Thanks,

    David
     

    Wednesday, December 5, 2007 11:45 AM

Answers

  • User2069888697 posted

    You should just need to make sure to set these fields on the AlbumID and PhotoID column properties.

    Identity Specification = yes

    (IsIdentity)=yes

    Identity Increment =1

    Identity Seed =1

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 5, 2007 3:47 PM

All replies

  • User2069888697 posted

    You should just need to make sure to set these fields on the AlbumID and PhotoID column properties.

    Identity Specification = yes

    (IsIdentity)=yes

    Identity Increment =1

    Identity Seed =1

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 5, 2007 3:47 PM
  • User1683925724 posted

    Excellent, thanks!

    Tried, tested and it works just fine.

    Regards,

    David
     

    Wednesday, December 5, 2007 5:10 PM