How do I tell if the Oracle client is installed

G

Guest

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.
 
G

Guest

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.
 
G

Guest

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;
}
}
}
 
W

WenYuan Wang [MSFT]

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.
 
W

WenYuan Wang [MSFT]

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.
 
W

WenYuan Wang [MSFT]

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top