2
Answers

Problem at connecting to a Oracle DB

Ask a question
yokzu

yokzu

12y
1.6k
1

Hi,

I want to connect an Oracle DB and do some works. So I add the "System.Data.OracleClient;" from references and my all codes are below;

-----------------------------------

 string connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.8)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=oracledb)));User Id=user;Password=password;";
            OracleConnection conn = new OracleConnection(connectionString);
            conn.Open();

            string query = "SELECT * FROM users WHERE LOCATION='" + textBox2.Text + "' ";
            OracleDataAdapter oadp = new OracleDataAdapter(query, conn);
            DataSet ds = new DataSet();
            oadp.Fill(ds);
            dataGridView1.DataSource = ds;
            conn.Close();

---------------------------------

The problem is, sometimes it is connecting to DB and sometimes its getting this error;"ORA-12545: Connect failed because target host or object does not exist error. ". And getting error on conn.Open() line.

I have no idea what is the problem? Why is this so hard to connecting to a Oracle DB? What should I install to my system?


Answers (2)