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?
yokzuPosted Apr 24, 2012, 8:36 AM
I change the reference to "oracle.dataaccess". But the problem is still continue.
Kunal VaishyaPosted Apr 24, 2012, 4:57 AM
try Another String
http://www.connectionstrings.com/oracle#p19
http://www.dofactory.com/Connect/Connect.aspx