Delete a thread error in Forums with db sqltie.

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
7/19/2009 10:09:33 PM
Gravatar
Total Posts 59

Delete a thread error in Forums with db sqltie.

OS: Winxp
DB:Sqlite
Version:2.3.1.0

 

Hi, Joe

When delete a thread in forums, error occurs, Below code in file ForumThread.cs

////////////////////////////////////////////////////

public static bool Delete(int threadId)
{
bool status = false;

ForumThread forumThread = new ForumThread(threadId);
using (IDataReader reader = DBForums.ForumThreadGetPosts(threadId))
{
while (reader.Read())
{
forumThread.DeletePost((int)reader["PostID"]); //(int)reader["PostID"] will fail
}
}

status = DBForums.ForumThreadDelete(threadId);

return status;
}

////////////////////////////////////////////////////

error information as below:

[InvalidCastException: 指定的转换无效。]
mojoPortal.Business.ForumThread.Delete(Int32 threadId) +183
mojoPortal.Web.ForumUI.ForumThreadEdit.btnDelete_Click(Object sender, EventArgs e) +71
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Thanks!

 

7/22/2009 7:52:29 PM
Gravatar
Total Posts 59

Re: Delete a thread error in Forums with db sqltie.

Hi, Joe:

There are two problems in this function:

1. forumThread.DeletePost((int)reader["PostID"]);

(int)reader["PostID"] will fail, use (long)reader["PostID"] or Convert.ToInt32(reader["PostID"]) is ok, but DeletePost need a int param, so

(int)reader["PostID"] should be changed to Convert.ToInt32(reader["PostID"]).

 

2.Sqlite is a file based database, so can't open it twice.

public static bool Delete(int threadId)
{
...

using (IDataReader reader = DBForums.ForumThreadGetPosts(threadId)) //have open it
{
while (reader.Read())
{
forumThread.DeletePost((int)reader["PostID"]); //can't open it again befor close it.
}
}

...

}

So maybe need add a new function as GetPostsByPage does, get the all postids in a DataTable first.

Thanks!

 

 

7/23/2009 6:12:29 AM
Gravatar
Total Posts 18439

Re: Delete a thread error in Forums with db sqltie.

Hi mjohn,

I just fixed this in my copy by getting the ids into a DataTable and then using Convert.ToInt32(row["PostID"]) 

Thanks for the bug report.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.