.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

Programmatically setting Agent Autostart properties

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :Sql Server

I've written a service to replace the SQL Server Agent service to be independent of Agent when moving to Express versions of SQL Server which do not include Agent.  Obviously on older 2000 MSDE versions I don't want Agent and my service running at the same time so I need to turn off Agent but there are SQL Server Properties such as under the General tab, "Autostart policies when the operating system starts" section and I need to uncheck the "Autostart SQL Server Agent".  In SQL Server Enterprize Manager I can right click the server then select properties and general tab.

How do I change that property either via T-SQL or via VB.NET to uncheck it?



View Complete Post

More Related Resource Links

Advanced Basics: Setting Word Document Properties the Office 2007 Way


The last time I wrote this column (March 2006), I shared an application that allows you to update all the Microsoft® Word documents in a folder and its subfolders. Each time the application finds a document in the specified path, it updates the document properties to match those you specified in the application.

Ken Getz

MSDN Magazine June 2006

Advanced Basics: Set Word Document Properties Programmatically


At the beginning of another lovely day of writing courseware in mad pursuit of unrealistic deadlines, I received a frantic call from a business partner. He was at the end of a long consulting project and had several hundred Microsoft® Word documents, all of which required their document properties to be set identically, except the Title property of the document, which was to be based on the document file name, minus the .

Ken Getz

MSDN Magazine March 2006

problem on Page_PreRender with RangeValidator control and programmatically setting Maximum and Minim

I am new to the ASP.NET /C# dev. I run into a weird bug when using the RangeValidator Control inside a Formview. I have my DateTime field with validator and it work fine until I submit the page, it actually insert the row into the database but then when the page reload I get the following exception.Server Error in '/Budget' Application. The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'. 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.Web.HttpException: The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [HttpException (0x80004005): The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'.] System.Web.UI.WebControls.RangeValidator.ValidateValues() +1077011 System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid() +12

Setting language settings programmatically MUI?!

Is it possible to set the language settings programmatically ?? Site settings > site administration > language settings and next programmatically select the installed language packs?

Change webpart properties programmatically

I am attempting to modify the properties of another webpart when my webpart's button is clicked. The code compiles and runs, and stepping through it shows that the properties do change. However, they don't stay changed. This example attempts to toggle the visibility state, but other properties won't stay changed either. Any help is appreciated.     SPSecurity.RunWithElevatedPrivileges(delegate() { // get the site in this context using (SPSite SiteCollection = new SPSite(mySiteGuid)) { // get the web in this context SPWeb myWeb = SiteCollection.OpenWeb(myWebGuid); myWeb .AllowUnsafeUpdates = true; // Hide/display another webpart. Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager mgr = null; mgr = myWeb.GetLimitedWebPartManager( "default.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared); foreach (System.Web.UI.WebControls.WebParts.WebPart myWebPart in mgr.WebParts) { // If this is the webpart we want to modify... if (myWebPart.Title == "Other Webpart Name") { // Toggle the visibility state. myWebPart.Visible = ! myWebPart.Visible; myWeb.Update(); break; } } } });

Styles: Setting Properties in deeper hierarchies


I'm not sure how to do a search on this, so I decided to rather ask it instead of doing hours of searching.

I have a class with DependencyProperties and use that class in a UserControl. I use that UserControl in a Window and in that Window I use the Window's Resources to set some Properties on the UserControl. I now like to set some DependencyProperties on that class, which would automatically reflect on the UserControl due the binding.

Is there a way to do it? I couldn't figure it out to do it in the .xaml, which is where I'd like to do this particular task.

Setting Options Programmatically in Visio 2010 for Publishing to SharePoint Server 2010

Explore how to programmatically save Visio 2010 diagrams as web drawings for use with Visio Services in SharePoint Server 2010.

Can a stored procedure programmatically determine the name of the SQL Agent job that executed it?



We have a SQL Agent job that runs a stored procedure.  Is it possible for the stored procedure to programmatically determine the name of the SQL Agent job that executed it?  (Without the agent job passing its name to the procedure through a parameter.)  How would you do it?

Thanks -


Setting Page properties from itself


Hi all,

Is there any easy way to set properties of a Page (or UserControl for that matter) from *within itself*?
As an example, I have several .aspx pages which inherit from exactly the same code-behind class, but I need to be able to pass different properties to the class to make them do the correct thing for the specific .aspx.

The only way I've found to do this is to create the following - which works fine, but doesn't feel right....
<script runat="server">
  Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
    Me.MyProperty = True
  End Sub

It would be a much nicer, simplier and easier solution to be able to be able to set MyProperty = True somewhere... is this possible?

The option of hard-coding properties within the class for the "parent" page is not going to work for my situation.

Many thanks in advance,
Tom Smile

Setting properties from a database


 I have a database which holds the path of an image. It also holds the recomended height and width of the image. My question is how can I set the height and width properties from my database? I have tried the following with no avail:

<asp:TemplateField HeaderText="Image" HeaderStyle-HorizontalAlign="Left">
                    <asp:Image ID="Image" runat="server" ImageUrl='<%# Eval("Image") %>'  Width='<%# Eval("Width") %>' Height='<%# Eval("Height") %>'/>


Any Ideas?

Thanks in advance

Programmatically Ignore Inherited Properties while iterating through object properties


Hi All,

I'm currently running a loop to iterate through an object properties:

Public Class Notification
    Inherits CommonProp
    Public Property NotificationID As Integer
    Public Property Message As String
    Public Property ReceivedDateTime As DateTime
End Class

However, when iterating through these properties, I do not want to iterate through the inherited CommonProp properties.

Is there anyway of ignoring the CommonProp properties?

Please kindly assist.

Thank you in advance.

Warmest Regards,


finding control id and setting properties in other pages


hi can anybody help me how to code,

im using a webusercontrol (hide.ascx) it has 2 buttons btn_hide,btn_expand

and in my other forms of all like(products.aspx)customers.aspx,orders.aspx

im using a panel conrol(pnl_products) where in im placing all the input controls.

i want to find the panel control in hide.ascx page and to set that

panel.visble=true/false property in this page.

so that expand and collapse the panel in each page.

Programmatically adding user profile properties fails when adding a multivalued property


I have written a console application that adds a custom section to the User Profile Properties and then adds properties under that section. The code works fine when adding CoreProperties of type string (Single Value) and mapping each property to an Active Directory field. However the code always fails when mapping a string (Multi Value) property to an AD property. I have researched the errors I present below but cannot see what the solution might be.


    private static void AddCustomProperties(string strUrl)
      Console.WriteLine("Adding custom properties under section '" + DisplayName + "'.......");
      using (SPSite siteColl = new SPSite(strUrl))

        SPServiceContext serviceContext = SPServiceContext.GetContext(siteColl);
        UserProfileConfigManager upcm = new UserProfileConfigManager(serviceContext);
        CorePropertyManager cpm = upcm.ProfilePropertyManager.GetCoreProperties();
        ProfilePropertyManager ppm = up

Setting "Reduce storage requirements for text properties by using a hash for comparison." using powe


Hey all,

I have a need to enable 'Reduce storage requirements for text properties by using a hash for comparison.' for a crawled property, i'd like to do this in my 'set search scopes' powershell script, where I define everything the crawler should be doing but I can't find the appropriate powershell command to do so, can anyone help?

At the moment I simply have one line setting up the property:


New-SPEnterpriseSearchMetadataManagedProperty -Name $preferredSandwich -SearchApplication $searchApp -Type 1  -RespectPriority 1 
-FullTextQueriable  1 -Retrievable 1 -IncludeinMd5 1	


Programmatically setting UpdateParameters for a SQLDataSource control


I need to provide defaults and sometimes overrides for items in SQLDataSource's UpdateParameters. I am attempting to do this in a FormView's ItemUpdating and ItemInserting events as follows:

    // FormView1_ItemUpdating:
    protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e) {
        // not sure if this is the bets place to put this or not?
        dsDataSource.UpdateParameters["UpdatedTS"].DefaultValue = DateTime.Now.ToString();
        dsDataSource.UpdateParameters["UpdatedUserID"].DefaultValue = ((csi.UserInfo)Session["UserInfo"]).QuotaUserID;
In the example above I am attempting to set new values for the parameters which will replace the existing values. 
I have found that using the DefaultValue property works ONLY if there is no current value for the parameter.  Otherwise the values

Setting Windows Services App properties programatically


I've got a Windows Services app I've deployed and I've used the System.ServiceProcess.ServiceInstaller to set the StartType to Automatic and that works great.

How do I set the action on failure to "restart" and the wait time to one minute?

Can't find those properties but if you open up a Service's properties in the UI, there's a Recovery Tab with First Failure, Second Failure etc. and a "Restart service after __ minutes"

Where do I set these properties for my service at design time before deploying??



Setting ShowInDisplayForm, ShowInEditForm, ShowInNewForm properties with powershell


I am trying to set ShowInDisplayForm, ShowInEditForm, ShowInNewForm properties of the filed in a custom list using powershell. This looks straightforward and powershell code is quite simple:

#get the site
$site = new-object Microsoft.SharePoint.SPSite("http://sv42104bosv271")
$web = $site.OpenWeb()
#get the list
$list = $web.Lists["MyList"]
#set col1
$field = $list.Fields["col1"]
$field.ShowInNewForm = "false"
$field.ShowInEditForm = "false"
$field.ShowInDisplayForm = "false"
#set col2
$field = $list.Fields["col2"]
$field.ShowInNewForm = "false"
$field.ShowInEditForm = "false"
$field.ShowInDisplayForm = "false"
#update & dispose

This runs without any error messages in “SharePoint 2010 Management Shell”, but the expected behavior is not being applied. I have also done an iisreset, but still col1 and col2 remain visible in all 3 forms...

Has anyone have a suggestion on this?

Thanks in advance!


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend