[Message Deleted]
-
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
-
Does that key exists on your box? on mine with sql2005 it doesnt...
-
I think the right path is : RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server"); :-D
-
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
-
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
-
if have problems getting machine name use: string name=Environment.GetEnvironmentVariable("computername");
-
if have problems getting machine name use: string name=Environment.GetEnvironmentVariable("computername");
-
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.
-
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