title: Oracle connection with port, service name, and database from C# (ORA-12514
body: <p>I'm new to Oracle.  Trying to connect C# windows app to an Oracle database but can't seem to establish a proper connection.  Keep getting exception: "ORA-12514: TNS:listener does not currently know of service requested in connect descriptor".  I have to specify the port, service name, and database name in the connection string because the service id has access to multiple databases. I know that the values in the string are valid (valid server, valid serviceid, valid username, password, etc) because I have a third-party tool that is able to connect using the same parameters from a wizard.  I've tried a lot of different ways to format the connection string but I always get the same 12514 error.  In the code example, you'll see three formats (cxn, cxn2, and cxn3), I've tried each of them but get the same error.</p>
  
  <pre><code>        string cxn = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyServerName)(PORT=MyPortNumber))" +
              "(CONNECT_DATA=(SERVICE_NAME=MyServiceId)));User Id=MyUserName; Password=MyPassword;";
  
          string cxn2 = "DATA SOURCE=MyServerName:MyPortNumber/MyUserName;" +
              "PERSIST SECURITY INFO=True;USER ID=MyUserName; password=MyPassword; Pooling = False;";
  
          string cxn3 = "DATA SOURCE=MyServerName:MyPortNumber/MyServiceId;" +
              "PERSIST SECURITY INFO=True;USER ID=MyUserName; password=MyPassword; Pooling = False;";
  
          using (OracleConnection conn = new OracleConnection(cxn3))
          {
              string sqlSelect = "SELECT * FROM PERSONS";
              using (OracleDataAdapter da = new OracleDataAdapter(sqlSelect, conn))
              {
                  var table = new DataTable();
                  da.Fill(table);
  
                  if (table.Rows.Count &gt; 1)
                      Console.WriteLine("Successfully read oracle.");
              }
          }
  </code></pre>
  
  <p>Again, I've used MyServiceId in the third-party tool's wizard and I connect just fine and select my database.  I'm using Oracle.ManagedDataAccess.Client. I consulted a number of articles online including <a href="http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/12c/r1/appdev/dotnet/Web_version_Fully_Managed_ODPnet_OBE/odpnetmngdrv.html" rel="nofollow noreferrer">Oracle's guidance in section "Getting Started with ODP.NET, Managed Driver"</a>.  How can I get the driver to recognize the valid service id and then also accept the database name? Any guidance is appreciated. Thanks.</p>