I used following code to connect oracle database from C#.
But i get this error "invalid login credentials"

using (Oracle.DataAccess.Client.OracleConnection cn = new Oracle.DataAccess.Client.OracleConnection("Data Source=abcSource;User Id=abcUserId;Password=abcPassword;") 

While if i try following code to connect database from C# I succeed.

using (System.Data.OracleClient.OracleConnection cn = new System.Data.OracleClient.OracleConnection("Data Source=abcSource;User Id=abcUserId;Password=abcPassword;"));  

I dont understand, what is happening
Please! Can anyone help me

Recommended Answers

All 2 Replies

The source should be the name of the server the DB is on and the catalog should be the name of the database so try adding a catalog attribute to the connection string just after the source attribute.

EDIT: Sorry my advice is for an SQL server database and not an Oricale DB.


In first method you have not closed ')' properly. you are missing one Close')' at the end of query and also missing ';'.


  I think you should try this as well.

     using System;
        using System.Data;
        using Oracle.DataAccess.Client; 

        class ConnectionSample
          static void Main()
            string connstr = "User Id=ID;Password=Pass;Data Source=SourceName";
            OracleConnection con = new OracleConnection(connstr);

Hope it will Work for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.