Must declare scalar value

Problem:

You have made a change to an insert method of an ASP.NET dataset, by adding one or more input parameters, and you've noticed that it has not updated the actual method in the generated code. When running the insert method you get the following error: "Must declare scalar value ..."

Solution:

One thing causing this could be that you have added "SELECT SCOPE_IDENTITY()" to the end of the SQL in the data set method. This will prevent the data set code generator from updating the method in the generated code even though it tells you the method has been updated.  Remove "SELECT SCOPE_IDENTITY()" from the SQL and add the variable. Update the dataset, compile the code and put the "SELECT SCOPE_IDENTITY()" back in. Remember to change the ExecuteMode property of the method back to Scalar!

Your problem is now solved.

Happy programming! :-)

Server Application Unavailable

If you receive the following, you should check the event log of your server to solve the issue. I once received this because the service account running the website did not have correct access rights. http://msdn.microsoft.com/en-us/library/kwzs111e.aspx

Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable.  Please hit the "Refresh" button in your web browser to retry your request.

Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.

Happy Programming!

How to find a control in an ItemTemplate on the ASP.NET Repeater control.

This problem seems to be occurring every once in a while on forums troughout the internet. This post will show you what to do.

The problem:

You would like to access a control in the item template on your ASP.NET repeater control, but every attempt to use "FindControl" on the repeater fails with the return of a null value. 

The solution:

You are using the wrong "FindControl" the solution is to use the repeater's "OnItemDataBound" event. This will give you access to the current repeater item using the event arguments. Like this:



/// <summary>
 /// Binds a navigate url to the hyperlink in the template.
 /// </summary>
 protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e) {
     HyperLink hyperLink = (HyperLink)e.Item.FindControl("headerHyperLink");
      hyperLink.NavigateUrl = CreateHyperlink((CalendarItem)e.Item.DataItem);
}


The trick is to use the "Item" property of the event argument. This is actually the template and using the FindControl on the "Item" property will give you the result you want.

Happy programming! :-)