Error deleting blog post

Topics: Help
Aug 11, 2007 at 4:34 AM
I get the following error when I try to delete a blog post.

Server Error in '/' Application.

Must declare the scalar variable "@postid0".
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: Must declare the scalar variable "@postid0".

Source Error:

Line 42:
Line 43: Dim cmd As New SubSonic.QueryCommand(sql)
Line 44: SubSonic.DataService.ExecuteQuery(cmd)
Line 45:
Line 46: Response.Redirect("~/blogs/default.aspx")

Source File: C:\Domains\\wwwroot\blogs\Post.aspx.vb Line: 44

Stack Trace:

SqlException (0x80131904): Must declare the scalar variable "@postid0".
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857370
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734982
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +192
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +380
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
SubSonic.SqlDataProvider.ExecuteQuery(QueryCommand qry) in SqlDataProvider.cs:196
SubSonic.DataService.ExecuteQuery(QueryCommand cmd) in DataService.cs:382
BlogsPost.HyperLink2Click(Object sender, EventArgs e) in C:\Domains\\wwwroot\blogs\Post.aspx.vb:44
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.819
Aug 11, 2007 at 2:25 PM
This was fixed in build 3923
Aug 23, 2007 at 2:41 AM
When a new build is released is the is the express version updated? I downloaded the newest build and located what seemed to be the same files as those found in the express version but I get errors. I'd try to list the errors but the maximum number of errors has been exceeded.
Aug 24, 2007 at 9:19 PM
Edited Aug 24, 2007 at 9:19 PM
Just replace the App_Code/BLL/blog.vb file.
Sep 18, 2007 at 9:39 PM
Edited Sep 19, 2007 at 12:26 AM

z2bass wrote:
Just replace the App_Code/BLL/blog.vb file.

I have just installed the starter pack express version today Version 3 beta 1 and Im recieving the same error, I also tried downloading the blog.vb file from the standard version and its still the same. Does anyone have any suggestions? Thanks.

Edit: I located the newest build as I wasnt using it before, I now dont get any error but it doesnt delete the blog comment when I click the delete button. Are there any more files I need to delete as the latest patched builds are all for the standard version and im running the express version. cheers.
Nov 19, 2007 at 3:03 AM
I am having the same error and I just downloaded the 3.1 beta about 3 days ago. However, it looked to me as if the problem is in an object that would have been compiled into the SubSonic.dll

BTW, where do you get these new downloads such as the blogs.vb?
Dec 8, 2007 at 2:28 PM
Edited Dec 8, 2007 at 2:33 PM
There have been 2 "fixes" posted and neither one fixed the problem. Did anyone check to see if maybe there is a new SubSonic dll that should be used. I mean it looks like that is where the error message is telling us the problem resides.

I realize this is a free application and that support is provided on a catch-as-can-catch basis, but if the moderator is not going to moderate can we at least get one who can. I don't know if there is no response because the problem is too difficult for the moderator to understand or answer, or if the moderator is too busy or if the moderator just doesn't care. Is there anyone out there who knows?
Jan 31, 2008 at 10:36 PM
Edited Jan 31, 2008 at 10:39 PM
I found the solution to this, add the following code to the Hyperlink2_Click procedure:

sql += "\r\n"
sql += " "

Dim cmd As New SubSonic.QueryCommand(sql) //this is already in there
Insert this:
Dim param As New SubSonic.QueryParameter()
param.ParameterName = "postid0"
param.ParameterValue = Request("id")

SubSonic.DataService.ExecuteQuery(cmd) //this is already in there

This worked for me, give it a shot.
Sep 18, 2009 at 8:03 PM

In VS2005std go to Edit/ Find&Replace/ Find in Files. Find what? = Hyperlin2_Click. Look in? = Entire Solution. Follow intstructions there.