Oracle Connection Error in C# code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kirubagari
    New Member
    • Jun 2007
    • 158

    Oracle Connection Error in C# code

    Code:
      <add key="DB_CONNECTION_STRING1" value="User Id=cimmgr;Password=cimmgr;Direct=true;Data Source=cimdev.world;Port=1521;SID=cimdev"/>
    Code:
          public void InsertintoDB()
            {
    
                string strSQL = "";
                string strDBType = System.Configuration.ConfigurationManager.AppSettings["DBType"];
                string strConn = System.Configuration.ConfigurationManager.AppSettings["DB_CONNECTION_STRING1"].ToString();
                string strInsertTableName_Sql = "CIMMGR.[dbo].ANSDATA";
                string strInsertTableName_Ora = "CIMMGR.ANSDATA";
                string strdatetime = "";
                
    
                strSQL = "insert into " +
                "ANSDATA " +
                "(EQID,CHAMBERID,MEMO,MESSAGE, reporttime, parameterid, ruleid, algorithmvalue, rulename, wafer, alarmaction, runreuslt) " +
                "Values('F1PGAM04', " +
                "'CHA', " +
                "'Sensor Alarm : Alarm','Sensor Alarm : {FDC SEC Alarm(Mean)} EQID=F1PGAM04,CH=CHA,Recipe=ST2SN6.1,Lot=LGQ50083.1,SVID=SIH4_TOP,LCL=6,UCL=8,Value=9.00667647058824', " +
                "to_date('2012-12-21 16:31:42','YYYY-MM-DD HH24:MI:SS'),'MFC3_Flow','75545','9.00667647058824', " +
                "'Testing Rule','LGQ50083.1_0','##INHIBIT_TOOL##','ALARM_SEND_OK') ";
    
                DbProviderFactory rfPF = DbProviderFactories.GetFactory(strDBType);
    
                if (rfPF != null)
                {
                    DataSet DS = new DataSet();
                    IDbConnection rfConn = rfPF.CreateConnection();
                    rfConn.ConnectionString = strConn;
                    IDbCommand rfCom = rfPF.CreateCommand();
                    rfCom.CommandText = strSQL;
                    rfCom.Connection = rfConn;
                    IDbDataAdapter rfDa = rfPF.CreateDataAdapter();
                    rfDa.SelectCommand = rfCom;
                    rfConn.Open();
                    rfDa.Fill(DS);
                    
                    DS.Tables["Table"].TableName = "ANSDATA ";
     
                    rfCom.ExecuteNonQuery();
                    rfConn.Close();
                }
              
    
    
            }
    Hi Experts,
    Attached is my code.I encounter error ORA-12545: Connect failed because target host or object does not exist when trying to open the connection.Do i need to do anything else in order for me to connect to the server
    When i try to tnsping it is running fine and im getting an OK(130) message.
    So where exactly am i going wrong
    Thanks
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    That error is telling you that the address provided doesn't exist, meaning something in your connection string isn't correct. I always use ConnectionStrin gs.com for showing what a connection string for a given db should look like, in this case Oracle.

    Comment

    Working...