简体   繁体   中英

Ora 12454 tns could not resolve the connect identifier specified

I have wcf that runs on windows 2008 R2 (oracle Client 32/64), and when i trying to update table, i am getting this error ora 12454 tns could not resolve the connect identifier specified ,if i run this on local pc all work's fine Update function is fine,but when i run this on server i getting error.

After a looking for answer i think it can be error in my connection string,but all sems ok to me.

  <connectionStrings>
    <add name="SnOracle" connectionString="Data Source=ORCL;User Id=Vn;Password=Vn;"/>
  </connectionStrings>

Here image of error

在此处输入图片说明

Here the part of update code

             using (OracleConnection con = new OracleConnection(connStr))
                            {
                                try
                                {
                                    con.Open();
                                    OracleCommand cmd = new OracleCommand();
                                    cmd.Connection = con;
                                for (int i = 0; i < Rows.Count; i++)
                                    {
        cmd.CommandText = "INSERT INTO SNXRATES" +  "(KOD_BANK, 

    TAARICH_ERECH,KODCURRBANK,RATE_TYPE,RATE_VALUE,FACTOR_1,SERIAL_IN,SERIAL_OUT1,
    SERIAL_OUT2,CURRBASE,SERIAL_OUT3 )" +

        "VALUES" +  "('" + Rows[i].KOD_BANK + 
    "','" + Rows[i].TAARICH_ERECH + "','" + 
    Rows[i].KODCURRBANK + "',"  + Rows[i].RATE_TYPE + 
    "," + Rows[i].RATE_VALUE + "," + Rows[i].FACTOR_1 + "," + Rows[i].SERIAL_IN + "," +

 Rows[i].SERIAL_OUT1 + "," + Rows[i].SERIAL_OUT2 + ",'" + Rows[i].CURRBASE + "'," + Rows[i].SERIAL_OUT3 + ")";

                                        cmd.ExecuteNonQuery();
                                    }

                                }
                                catch (Exception ex)
                                {
                                    //here i use  MessageBox to see error
                                    MessageBox.Show(ex.Message+"  || "+ex.Source);
                                    succeeded = false;
                                }

                            }

                        }
                        return succeeded;

                    }

The main Reason behind this particular error is that on your server this particular TNS entry is not present. so what you can do is configure your oracle client on server to use tnsnames.ora file.

1)Find tnsnames.ora (Oracle client) and add respective entry(your connection which you have configured to use in your configuration file of your wcf service). ( http://kb.tableausoftware.com/articles/knowledgebase/oracle-connection )

2)Reset(or restart) your IIS(if used any or restart your wcf service on server).

3)Try again to execute your code.

find the tnsnames.ora file. it may be on C: or D: drive. Probabily the path is as follows : ..\\app\\Administrator\\product\\11.2.0\\client_1\\network\\admin. Add the tns setting here for your db that you are using in application then run the application. it may work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM