Error connecting to oracle database using web programming in .NET

0

When attempting to connect to the bank, I got the error according to the attached image. My application is web in .net, visual studio 2010, database oracle sql developed 3.1.07.

My code where you get the error:

protected int GetRowCounts()
    {
        int iRowCount = 0;


        using (OracleConnection conn = new OracleConnection("DATA SOURCE=DAPP;PASSWORD=APL_SD7#PP4;USER ID=APL_SDP"))
        {
            OracleCommand cmd = new OracleCommand("select count(*) from SDPJ_IMPORT_PROCESSO", conn);
            conn.Open();

            // Executa o SqlCommand e obtendo as contagens da linhas.
            iRowCount = (int)cmd.ExecuteScalar();
        }

        return iRowCount;
    }

    
asked by anonymous 21.02.2018 / 17:45

2 answers

1

Check the directory

  

C: \ app \ product \ 11.1.0 \ client_1 \ network \ admin

and look for the tnsnames.ora file, within that file there will be the database access settings. It loads these settings to access the database, if any data is wrong, it can not load that information and triggers the error you reported.

    
21.02.2018 / 19:05
0

This GetRowCounts() method is protected access. Which means it will only run within the class itself. If you are trying to run it in another class then you need to change the method access to public or create a public access method in the same class as GetRowCounts() call it into this new method and run the new method in the place where you want it.

    
21.02.2018 / 18:14