DB Null error when loaing the default page

Topics: Developer Discussion, Help
Jan 2, 2009 at 9:46 PM
I have just downloaded Club starter kit 2.0. When I run this using the clubDB.mdf, it works extremely fine. WhenI was trying to create the same type of database on my hosting server and run using the remote server, I receive the below error. Could anyone please help me in resolving this

<title>Object cannot be cast from DBNull to other types.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style>

Server Error in '/' Application.

Object cannot be cast from DBNull to other types.

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.InvalidCastException: Object cannot be cast from DBNull to other types.

Source Error:

Line 90:         Public Shared Function GetLatestQuestion() As PollQuestion
Line 91: 
Line 92:             Dim qry As New Query(Tables.PollQuestions)
Line 93:             qry.Top = "1"
Line 94:             qry.OrderBy = OrderBy.Desc(PollQuestions.Columns.CreationDate)

Source File: C:\Code_source\ClubStarterKit.Web\App_Code\BLL\Poll.vb    Line: 92

Stack Trace:

[InvalidCastException: Object cannot be cast from DBNull to other types.]
   System.DBNull.System.IConvertible.ToBoolean(IFormatProvider provider) +54
   System.Convert.ToBoolean(Object value) +25
   SubSonic.SqlDataProvider.GetTableSchema(String tableName, TableType tableType) in C:\SubSonic 2.0.3\src\SubSonic\DataProviders\SqlDataProvider.cs:458
   SubSonic.DataService.GetSchema(String tableName, String providerName, TableType tableType) in C:\SubSonic 2.0.3\src\SubSonic\DataProviders\DataService.cs:426
   SubSonic.DataService.GetTableSchema(String tableName, String providerName) in C:\SubSonic 2.0.3\src\SubSonic\DataProviders\DataService.cs:440
   SubSonic.Query.BuildTableSchema(String tableName, String providerName) in C:\SubSonic 2.0.3\src\SubSonic\Sql Tools\Query.cs:497
   SubSonic.Query.BuildTableSchema(String tableName) in C:\SubSonic 2.0.3\src\SubSonic\Sql Tools\Query.cs:492
   SubSonic.Query..ctor(String tableName) in C:\SubSonic 2.0.3\src\SubSonic\Sql Tools\Query.cs:651
   ClubStarterKit.Web.Poll.GetLatestQuestion() in C:\Code_source\ClubStarterKit.Web\App_Code\BLL\Poll.vb:92
   ClubStarterKit.Web.Controls.PollControl.LoadQuestion() in C:\Code_source\ClubStarterKit.Web\App_Code\Controls\PollControl.vb:86
   ClubStarterKit.Web.Controls.PollControl.OnLoad(EventArgs e) in C:\Code_source\ClubStarterKit.Web\App_Code\Controls\PollControl.vb:102
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

Jan 3, 2009 at 8:59 PM
I believe this bug has since been fixed. If not, the issue is with there being no Poll Questions, did you happen to delete them? Add another Poll Question and it's answers via the database and it should resolve this. Perhaps somebody else has an easier idea but this should do the trick.
Jan 4, 2009 at 3:12 AM
Am I missing something? ClubstarterKit 2 does not have poll's.