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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

ServerInstances of ManagedComputer is empty

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

I am trying to turn on TCP and Named Pipes for a given SQL Server instance.  I have used the same code on several different scenarios successfully but just encountered errors on Windows 7 64 bit.  Using SMO 2008, when I try to access the ServerInstances collection, an exception is thrown.  I have double checked and the collection is in fact empty.  The instance I am trying to access is SQLEXPRESS, although the code allows any instance to be passed.  I have double checked that the instance name being passed is correct.

Has anyone else experienced this or does anyone know how to fix the problem?



      Dim mc As New Wmi.ManagedComputer()
      Dim sp As Wmi.ServerProtocol
      sp = mc.ServerInstances(strInstanceName_).ServerProtocols("Tcp")

      If Not sp.IsEnabled Then blnNeedsRestart_ = True

      sp.IsEnabled = True


      sp = mc.ServerInstances(strInstanceName_).ServerProtocols("Np")

      If Not sp.IsEnabled Then blnNeedsRestart_ = True

      sp.IsEnabled = True

View Complete Post

More Related Resource Links

How to check for null/empty strings on dynamic objects?


What is the proper way to check for null or empty strings on dynamic objects? This is the only solution I've found so far:

if (admin.PasswordHash.GetType() == typeof(DBNull) || admin.PasswordHash == string.Empty)

If the field is null, the object returned is DBNull.Value, but if the field is empty string, it's return as a System.String object. This makes it impossible to do regular "admin.PasswordHash == DBNull.Value" check, as that will fail whenever the field has been set to empty string. Is my example the right (and only) way to go?

http/localhost is empty


I have Win , I install the following

in Internet Information Service->

Web Management Tools (check)

Application Development Features I check (.Net Extensibility, ASP.net, ISAPIExtensions, ISAPIFilterd,  I can see  IIS Manager under my Administrative tool , but when I call


I  can't see the welcome page , what is wrong

thank you!

Empty template support for GridView


Just add the following to support the empty text in the GridView.


protected override void RenderContents(HtmlTextWriter writer)
	if (Extender.AdapterEnabled)
		GridView gridView = Control as GridView;
		if (gridView != null)
			if ((gridView.Rows.Count == 0) && !String.IsNullOrEmpty(gridView.EmptyDataText))
				writer.WriteAttribute("class", "AspNet-GridView-Empty");

Example of tag to be added to the css
.NiceGridView .AspNet-GridView div.AspNet-GridView-Empty
	border-width: 1px;
	border-style: solid;
	border-color: #

Add an empty line in Gridview on specific dayofweek


Hey all,

Havin quite a bit of trouble with this one.  I have a bunch of days that I worked in my database...mostly monday-friday and some saturdays.  What I want the gridview to do is add an empty line between each sunday and monday so that it seperates out my work weeks and makes it easier to read in the gridview.  I got some help here a few days ago on how to clone the db etc and I have all that working properly but I can't seem to wrap my head around how to do add these empty lines in the proper spots.  Here is my code so far:

private DataTable AddEmptyRow()
        DataTable originalDataTable = GetItems();
        DataTable newDataTable = originalDataTable.Clone();
        DateTime testdate = Convert.ToDateTime("7/20/2010");

            for (int i = 0; i < originalDataTable.Rows.Count; i++)
                DayOfWeek day = testdate.DayOfWeek;

                if (day == DayOfWeek.Sunday)
                    DataRow newDataRow = newDataTable.NewRow();



Empty Website Data Source windown


Hi all,

I am Visual Web Developer user and facing a problem when I am creating a local report (.rdlc) file.

I am using Business objects as the Data Source for this report. It was working perfectly until all the items in the Website Data Source window suddenly "disappeared". The "Add New Data Source" button on this window is also disabled. Now the window is just like a blank box only. And I can't continue working with the report file like this...

I have tried undoing what I did before but it does not help at all...

Any reason for this to happen? There is no sign or something at least indicating what is wrong.

Please help.


 ps: found a similar thread in this forum but not solved

Dropdown menu - Null or empty string??


I have drop dowm menu as follow.

<asp:ListItem Value="">none</asp:ListItem>
<asp:ListItem Value="STO">Stock</asp:ListItem>
<asp:ListItem Value="ORD">Order</asp:ListItem>

If I chose none, it stores data as "Null"

If I Query the data as below, I don't get the data has value of "Null"

SELECT tabale From type Where type <> STO or type <> ORD

I get data that has empty string but not Null.

Here is my question.

1, How do I write dropdown menu value in oder to get empty string instead of Null?
I did <asp:ListItem Value="">none</asp:ListItem> but this stores Null.

2, Why this Query won't pick up Null?
SELECT mytabale FROM type WHERE type <> STO or type <> ORD

Thank you for your help.

asp.net VS-2005 Website Data Sources is empty



When I create a rdlc file(Report) the dialog box : "Website Data Sources" is empty, I can add a typed dataset, but the buisness objects (Classes) I created sometime disappear and sometime shown,

When I click/ remove some references it show and hide.

I would really appriciate some help,

thanks in advance,


I followed:


It works fine but after a while, it disappears again.

I tried it on several computers(which means it's not a problem of my machine), and tried it on several projects, all behave the same.


VS2005 calling VS2010 asmx service returns empty string


Anyone have any experience with this?

We are using VS 2005 for the front end, and vs 2010 for the web services part (asmx), not wcf yet.


Web service works just like the vs2005 when run locally, no problems.


Connecting to it from a test app returns an empty string. Connecting to a 2005 app doesn't!

Anyone run into this before or have a suggestion? Surely vs 2005 can connect to web services from a later version?






Values in user control fields empty when AutoEventWireup=true ?

As a BizTalk developer I'm trying to build a ASP.NET website so some obvious things might be new to me (so please be gentle). I have a web form and I have a user control on it. This user control contains a panel with some user properties that are to be stored in a database. So far nothing fancy. The user control itself contains a panel and is working fine (all code to retrieve and store the values is working). I used the default settings of creating a user control and one of them was AutoEventWireup=true. This works fine because I also have some dropdown boxes (and other fields) that need to be filled with values from the database and that happens in the Page_load event. The panel specifies the 'DefaultButton' which calls a method when clicked to save the values after the user has changed them. On this click the code of the method is called, I confirmed that, but I found out that the values of my controls on the user control (for example the Textbox control) are empty. As a non-ASP.NET developer I couldn't figure out why. So I changed some settings like AutoEventWireup to false. Off course this resulted in my dropdown boxes no longer to be initially filled, but my surprise was big to find out my controls actually contained the values the user typed in. Logically I need both the values and th

error in MVC2 on empty string form fields which are required: "This property cannot be set to a null

In model I have:[DisplayName("ISBN")] [Required(ErrorMessage = "ISBN is required.")] [StringLength(50, ErrorMessage = "ISBN book must have max {1} chars.")] [DisplayFormat(ConvertEmptyStringToNull = false)] public string isbn { get; set; }But when I submit form with empty field ISBN I have an error - ConstraintException: This property cannot be set to a null value.I have find that other people have the same problem and they say that debbugger in VS2010 works wrong - yes ?http://p2p.wrox.com/book-professional-asp-net-mvc-2/79788-constraintexception-unhandled-user-code.html#post259245http://efreedom.com/Question/1-3129080/Server-Side-Validation-REQUIRED-String-Property-MVC2-Entity-Framework-Workhttp://mvcmusicstore.codeplex.com/workitem/6604

Moving Membership tables to production; empty

Hi all: I'm currently moving my application from my testing environment, onto our live environment.  I've moved my database, including all membership tables over, and everyting is empty.  Again, this is what I wanted.  The test environment had far too much "crap" data, including fake user, so I wanted to just start from scratch on the production environment.  I don't know how to re-create the application or the first user though in these membership tables??  I'm sure this isn't an odd thing to do, but I havent' had any luck yet with finding an answer of how to do this.  Any help is greatly appreciated! Thanks, Terri-Lynn 

Varchar string to int - how to convert empty cells to nulls

Hi, I have a large table from which I want to convert certain columns from varchar to int while loading the table to another table. However, I run into problems when the input column contains empty cells. The SSIS data conversion data flow item can't handle these so I tried the script component. With the script component I can convert these empty cells to zeros but after that I'd need to use SQL update to update the zeros to nulls which in the case of a large table with over 3 million rows takes unnecessarily long. So, is there another way?

WebPart has empty viewstate on postback

I have a simple weather web part in the form of a user control.  This usercontrol has an update panel and a textbox to allow the user to enter in a zip code/ city etc and an ok button.  The problem comes in when the webpart is added or dragged outside of Zone 1.  If this webpart remains in Zone 1 everything is fine.  If it is in Zone 2 or 3 after entering a zip code and hitting ok and posting back the value of the textbox is always blank.  It seems like the viewstate is cleared or the control is loading for the first time.  I have checked the Page.IsPostBack property and it is indeed True.  What would cause my control to loose the value entered in the textbox only when it resides outside of Zone 1?

JPEGS with empty IPTC / APP14 Tags cause GDI+ error

I am curious as to why the GDI+ libraries error our with exc = {"A generic error occurred in GDI+."} when the IPTC headers are empty.  I would assume it should reasonably take care of this.  I have taken am image and changed the "ff ed" app14 marker to more generic "ff ec" and everything loads fine and dandy.  So by analysis I am looking at a jpg the IPTC header has no data and I am guessing the GDI+ libraries dont handle empty data very well.  Anyone else having this problem.  Only workaround which is expensive is creating a new image and saving it to the stream which in a sense basically strips the header data making it more generic of an image.   System.Drawing.Image image = Image.FromFile("c:\\test6.jpg"); System.Drawing.Image image2 = null; ImageFormat format = ImageFormat.Jpeg; using (var stream = new MemoryStream()) { try { image.Save(stream, format); //using jpg with empty IPTC data will throw GDI+ error } catch (Exception exc) { image2 = new Bitmap(image);//this is expensive but gets job done image2.Save(stream, format); } context.HttpContext.Response.BinaryWrite(stream.ToArray()); } JPG Hex Bytes from beginning of file.  The Internal of the stream will error out about 24 bytes with a lengt

New Jobs Are Empty

I'm truly seeing smoething very strange with MSDB and SQL Agent jobs... I can go out and create a new job under SQL Server Agent. It can be as simple as "SELECT * FROM SYSDATABASES". I clck okay. The dilog exits. The job appears under "JONBS" in the SQL Server Agent tree. When I go to view the Proppoerties of the job I just created, there are none! I get the New Job window!! It's as if the row gets created in sysjobs in MSDB, but there are no job steps or anything that is saved. It even asks as though I'm creating an entirely new job, even though I'm double clicking on an existing job. What is going on here? Never seen this before!! Thanks!A. M. Robinson

Empty/blank group at top of matrix table

I'm having trouble creating a report with matrix tables.  I've got all the data showing up properly, but the first line in the preview is always blank.  If I subtotal the groupings, I get a blank Total line as well.  How can I stop this from happening? I'm using SQL 2005, report designer.  Data is coming from a stored procedure.  I've executed the sp in management studio as well as in the data tab of the report and it comes back with the correct data (no completely blank/null lines).  I'm new to SSRS and I've tried googling for a solution, but haven't found anything similar.  Below is the sp and the output data. SP: SELECT s.Status_Name + ' (' + CAST(CAST(s.Status_Weight*100 AS int) AS varchar(50)) + '%)' AS Status, s.Status_Order, CASE WHEN co.Company_Name IS NULL THEN '' ELSE co.Company_Name END AS Company_Name, co.Est_Income FROM tblStatus AS s LEFT OUTER JOIN tblCompany AS co ON (co.Status_ID = s.Status_ID AND co.New_Upsell = @NewUpsell) GROUP BY co.Company_Name, s.Status_Order, s.Status_Name, s.Status_Weight, co.Est_Income ORDER BY s.Status_Order, co.Company_Name Output (mgmt studio): Still Connecting (0%),1,Company1,400000.00 Still Connecting (0%),1,Company2,3000000.00 Clear Future (0%),2,Company3,250000.00 Clear Future (0%),2,Company4,250000.00 Appointment (10%),3,,NULL Proposal (40%),5,,NUL

FormView with empty Byte Fields

I have a FormView with a byte field.  The field is not required and if I don't enter a value, I get an error that the value is not acceptable in a byte field.  I can replace the null value with 0 but I would prefer not to. What is the best way to handle this so that if I do not enter a value in a byte (or int16) field to insert a null value (or whatever they do in the ASP.net).   THanks for your help. 
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