How do I tell if the Oracle client is installed

  • Thread starter Thread starter Guest
  • Start date Start date
Hi,
Try this code:
Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\ORACLE");

if(key == null)
MessageBox.Show("Oracle not installed on client machine");
Hope this helps.
 
Hi,
A little correction in my code in previous post.It should be like this:
Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Oracle");
if(key == null)
MessageBox.Show("Oracle not installed on client machine");
Hope this helps.
 
Hi,
Below method is not elegant one but simple and reliable.You can do something
like this:
using System;
using System.Data;
using System.Data.OracleClient;

public bool IsOracleInstaled()
{
string connectionString = GetConnectionString();

using (OracleConnection connection = new OracleConnection(connectionString))
{
try
{
connection.Open();
return true;

}
catch (Exception ex)
{
return false;
}
}
}
 
I agree with Manish.
In my opnion, trying to connect Oracle server in coding is the simplest
(safest) way to check whether Oracle client software has been installed on
machine.

Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Dave
Thanks for your reply.

Have you tried "OracleConnectionStringBuilder"? This is a new class
introduced in .net framework 2.0. Pass ServerName, PassWord and UserName to
this builder. It will build a correct connection for you. Hope this helps.

http://msdn2.microsoft.com/en-us/library/system.data.oracleclient.oracleconn
ectionstringbuilder.aspx
[OracleConnectionStringBuilder Class]

Please let me know if you still have any concern on this. I'm glad to work
with you.
Sincerely,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Dave,
Thanks for your reply.

As far as I know, we can detect whether the Oracle Client has been
installed by Register key or connection.

If you truly do not want to get a connection string from user, I'm afraid
the only way is checking RegistryKey.

Another choice, you may use both. You may check the registry key and then
try to connect Oracle Database....

I also appreciate for any other better solution.
Sincerely,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi,
I know it is now too late but i have found solution for what you were
looking.Try this code:
If( Environment.ExpandEnvironmentVariables("%ORACLE%").ToString().ToUpper()
<> "%ORACLE%")
MessageBox.Show("Oracle is installed")

I have found that if oracle is installed then
Environment.ExpandEnvironmentVariables("%ORACLE%").ToString() gives path to
installation folder.
 
Back
Top