Hi Guys,
I am trying to make a connection with Oracle 11g which is installed on a server 2008 BUT have problems with the ConnectionString.

Could you please let me know how I set a correct connection String while I have parameters like these:
Database name: GISData
Server Name : SRV_GISSER
Port : 1521
User Name : Example
Password: : PExample
I already tried the to take alook at this page
http://www.connectionstrings.com/oracle
but I could not figure out which one is the best choice and how to use them, so please do not send me there again
I used this standard code which could not make any connection

private string oraConnectionString = "Provider=msdaora;data source = GISData ;user id= Example; password=PExample;";
        private OleDbConnection oraConnection;
oraConnectionString = String.Format(oraConnectionString);
                oraConnection = new OleDbConnection(oraConnectionString);
               
                oraConnection.Open();

I really appreciate your time and effort in advanced if you can help me to find it out
how to make a simple connection with ORACLEEEEEEE.
I believe that i am missing the Server and port parameter but how I can use them?
Thanks

Recommended Answers

All 12 Replies

What Oracle data provider have you installed? What error are you getting?

Hi Momerath
I download a System.Data.OracleClient dll file and add it to the project reference.Is this what you were asking for?

Not yet, as there are at least four different ones. Where did you download it?

I don't remember I just google it and download.what do u mean of there are at least four different ones?

I mean that there are different implementations of the Oracle connector for .NET. Oracle has one, Microsoft has one, and several other companies have created them. Depending on which one you are using the connection strings can have subtle differences, or you need to install Oracle's TSNames (I believe that's the name), etc. This is why I asked.

I am sorry Momerath,
I have no idea what are these? I make a connection with with SQL Server very simply but connecting to Oracle looks like lots of headache.As I already said I used "Provider=msdaora" in my connection string and OleDbConnection class.

Using OleDb is different :) Try

Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;OLEDB.NET=True;

If it doesn't work, post the error message you get as it might help me understand what you have installed.

Thanks my friend.
I have to test it on Monday while I have them installed on my work place desktop.I will post you the result for sure

Hi Momearth,
Sorry for late reply.I tried the following connection string
Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;OLEDB.NET=True;

an I got this error
Keyword not supported: 'provider'.
Do I have to install another dll?

Here is the exact code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.OracleClient;


namespace Oracle_Connect_Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text = "";
        }

        private void btnCon_Click(object sender, EventArgs e)
        {
            OracleConnection con = new OracleConnection();
            con.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;OLEDB.NET=True;";
            con.Open();
            
        }
    }
}

I just tried to connect to database and if connection was OK the label(label1) displays
Connection Ok

The connection string you have used in your program is belongs to System.Data.OleDb data provider API.

You need to use Oracle data provider connection string.

string str="Data Source=server_name_or_name_of_machine;Persist Security Info=True;User ID=your_username;Password=your_password;Unicode=True";

OracleConnection con = new OracleConnection();
con.ConnectionString = str;
con.Open();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.