Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved ASP.NET
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    [Message Deleted]

    S R R 4 Replies Last reply
    0
    • L Lost User

      [Message Deleted]

      S Offline
      S Offline
      Sandeep Akhare
      wrote on last edited by
      #2

      Thats what dubug the application and check which object is null ..

      swetha sankaran wrote:

      String[] instances = (String[])rk.GetValue("InstalledInstances");

      Make sure that rk is not null have if block there and check if (rk != null ) then do that

      Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... " Check My Blog

      1 Reply Last reply
      0
      • L Lost User

        [Message Deleted]

        R Offline
        R Offline
        Rolando CC
        wrote on last edited by
        #3

        Does that key exists on your box? on mine with sql2005 it doesnt...

        1 Reply Last reply
        0
        • L Lost User

          [Message Deleted]

          R Offline
          R Offline
          Rolando CC
          wrote on last edited by
          #4

          I think the right path is : RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server"); :-D

          1 Reply Last reply
          0
          • L Lost User

            [Message Deleted]

            R Offline
            R Offline
            Ryomin
            wrote on last edited by
            #5

            Perhaps you need to create a new instance of your RegistryKey. Try the using key word

            using(RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft SQL Server"))
            {
            String[] instances = (String[])rk.GetValue("InstalledInstances");
            //Rest of your code goes here
            }

            Not entirely sure if that will work for you. Good luck

            Cheers Disgyza Programmer Analyst

            L 1 Reply Last reply
            0
            • R Ryomin

              Perhaps you need to create a new instance of your RegistryKey. Try the using key word

              using(RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft SQL Server"))
              {
              String[] instances = (String[])rk.GetValue("InstalledInstances");
              //Rest of your code goes here
              }

              Not entirely sure if that will work for you. Good luck

              Cheers Disgyza Programmer Analyst

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              [Message Deleted]

              R R 2 Replies Last reply
              0
              • L Lost User

                [Message Deleted]

                R Offline
                R Offline
                Rolando CC
                wrote on last edited by
                #7

                if have problems getting machine name use: string name=Environment.GetEnvironmentVariable("computername");

                L 1 Reply Last reply
                0
                • R Rolando CC

                  if have problems getting machine name use: string name=Environment.GetEnvironmentVariable("computername");

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  [Message Deleted]

                  R 1 Reply Last reply
                  0
                  • L Lost User

                    [Message Deleted]

                    R Offline
                    R Offline
                    Rolando CC
                    wrote on last edited by
                    #9

                    maybe: Enumerate SQL Server Instances in C#, Using ODBC[^] or http://davidhayden.com/blog/dave/archive/2006/04/14/2915.aspx[^] I hope it works.

                    1 Reply Last reply
                    0
                    • L Lost User

                      [Message Deleted]

                      R Offline
                      R Offline
                      Ryomin
                      wrote on last edited by
                      #10

                      You could try using this:

                      using(Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer m = new Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer())
                      {
                      foreach (ServerInstance si in mc.ServerInstances)
                      {
                      Response.Write("ServerInstance:" + si.Name + "
                      ");
                      }
                      }

                      You'll probably have to add a Reference to Microsoft.SqlServer.Smo Best of luck

                      Cheers Disgyza Programmer Analyst

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups