Monday, August 8, 2011 5:30 PM
Often it is necessary to set the ServiceName for a Windows service at the time of installation. This is helpful when there will be more than once installation of the same server or if a installation specific name is needed. One way to set the ServiceName is to pass a parameter during installation that is read by the Installer Class:
private void BeforeInstallEventHandler( object sender, InstallEventArgs e )
// Add steps to perform any actions before the install process.
string name = Context.Parameters["ServiceName"];
if ( name != null )
serviceInstaller.ServiceName = name;
serviceInstaller.ServiceName = "YourServiceName";
The InstallContext.Parameters Property is used to obtain the parameters that were used when the installutil.exe was run. In the above example (don't forget your exception handling) if the parameter "ServiceName" is used then the service is installed with the name specified. If it is not specified then the "default" servicename is used.
The installation of the service could be executed with the following:
Sunday, August 7, 2011 1:32 PM
The stored procedure sp_spaceused can be used to determine the reserved and used disk space for a database or specific objects (tables or indexed views) within a database. If sp_spaceused is called without an @objectname (table or indexed view) the results are displayed for the database. If an @objectname is specified then the results are displayed for the object specified.
EXEC sp_spaceused '@TableName'
To list information for all of the tables within a database the undocumented procedure sp_MSforeachtable can be used:
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
Sunday, July 17, 2011 3:15 PM
ASP.NET , C# , Code
To programmatically set the InnerHtml of a <div> control in a web form set the <div> control to runat = ”server”:
<div id="myDIV" runat="server">
With the <div> set to run on the server it is accessible via the codebehind page:
myDIV.InnerHtml = "<font color='red'>Message</font>";