Delete a thread error in Forums with db MSSQL.

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:54:07 PM
Gravatar
Total Posts 59

Delete a thread error in Forums with db MSSQL.

OS: Winxp
DB:MSSQL
Version:2.3.1.0

 

Hi, Joe

When Delete a thread in forums wiht MSSQL(not witt sqlite)  db ,error occurs:

Below code in EditThread.aspx.cs

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

private void btnDelete_Click(object sender, EventArgs e)
{
ForumThread.Delete(this.threadId);
Forum.UpdateUserStats(-1); // updates all users, error occurs.

if (hdnReturnUrl.Value.Length > 0)
{
WebUtils.SetupRedirect(this, hdnReturnUrl.Value);
return;
}

WebUtils.SetupRedirect(this, SiteUtils.GetCurrentPageUrl());
}
///////////////////////////////////////////////////

 

Then code go into file SQLParameterHelper.cs:

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

private void DefineSqlParameter(
String paramName,
SqlDbType type,
int size,
ParameterDirection dir,
object value,
bool sizeProvided)
{
...................
Debug.Assert(arParams[index].Direction == dir, "parameter's direction doesn't match cached parameters");
Debug.Assert(string.Equals(arParams[index].ParameterName,paramName, StringComparison.InvariantCultureIgnoreCase), "parameter's name doesn't match cached parameters");
//this errors because  arParams[index].ParameterName  is "@UserID"  but  ParameterName is UserID,lack a @, So error occurs.
Debug.Assert(
((type != SqlDbType.NText)
&& (arParams[index].SqlDbType == type))
||
((type == SqlDbType.NText)
&& (arParams[index].SqlDbType == SqlDbType.NVarChar))
||
((type == SqlDbType.Image)
&& (arParams[index].SqlDbType == SqlDbType.VarBinary))
, "parameter's type doesn't match cached parameters"
);

arParams[index].Value = value;
index++;
}

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

And maybe have some other problem, because when i delete a thread, the page  can't redirect to the right page.

Thanks!

7/20/2009 6:16:41 AM
Gravatar
Total Posts 18439

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

Hi mjohn,

Thanks for the bug report I found the bug in DBForums.cs:

public static bool UpdateUserStats(int userId)
{
SqlParameterHelper sph = new SqlParameterHelper(GetConnectionString(), "mp_Forums_UpdateUserStats", 1);
sph.DefineSqlParameter("UserID", SqlDbType.Int, ParameterDirection.Input, userId);
int rowsAffected = sph.ExecuteNonQuery();
return (rowsAffected > -1);
}

as you said it was missing the @ for the parameter. I've fixed it here.

I need to look at that redirect when deleting a thread, it seems because the thread no longer exists it results in the access denied page. Need to do something more graceful there.

Best,

Joe 

7/22/2009 2:13:08 AM
Gravatar
Total Posts 59

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

When delete the last post  of a thread, the page will redirect to a thread that did not exist it results in the access denied page.

7/22/2009 6:27:20 AM
Gravatar
Total Posts 18439

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

I just now added code to redirect back to the list of threads if the thread does not exist. 

Thanks,

Joe

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