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.
When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:
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!
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.
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