Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

OracleConnection (OracleClient) works in VB.NET but not C#

Posted on 2007-07-26
5
Medium Priority
?
2,843 Views
Last Modified: 2013-11-07
Hi all, I am using the Microsoft OracleClient 1.0.3300.0 from within VS 2005

I am having a bit of trouble connecting to the oracle DB from a C# application, the strange thing is that it works in VB!
THIS WORKS CORRECTLY:
----------------------------------------------------------------------
Dim conn As New System.Data.OracleClient.OracleConnection("SERVER=(DESCRIPTION=(ADDRESS=(COMMUNITY=xxx.world)(PROTOCOL=TCP)(Host=xxx)(Port=xxx))(CONNECT_DATA=(SID=xxx)));uid=xxx; pwd=xxx; Integrated Security=no;")
        Dim dt As New DataTable
        Try
            conn.Open()
            Dim DA As New System.Data.OracleClient.OracleDataAdapter("SELECT * FROM TABLENAME", conn)
            DA.Fill(dt)
        Catch ex As Exception

        Finally
            conn.Close()
        End Try
        Me.GridView1.DataSource = dt
        Me.GridView1.Databind()
----------------------------------------------------------------------

so with that working I created an app in C# with the following code (a simple translation from vb to c#):

----------------------------------------------------------------------
OracleConnection conn = new OracleConnection("SERVER=(DESCRIPTION=(ADDRESS=(COMMUNITY=xxx.world)(PROTOCOL=TCP)(Host=xxx)(Port=xxx))(CONNECT_DATA=(SID=xxx)));uid=xxx; pwd=xxx; Integrated Security=no;");
        DataTable dt = new DataTable();
        try
        {
            conn.Open();
            OracleDataAdapter DA = new OracleDataAdapter("SELECT * FROM TABLENAME", conn);
            DA.Fill(dt);
        }
        catch (Exception ex)
        {
        }
        finally
        {
            conn.Close();
        }
        this.GridView1.DataSource = dt;
        this.GridView1.DataBind();
----------------------------------------------------------------------

the error given is
      [System.Data.OracleClient.OracleException]      {"ORA-12638: Credential retrieval failed\n"}      System.Data.OracleClient.OracleException


any ideas why it would work in VB and not in C#?
0
Comment
Question by:Solar_Flare
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:JimBrandley
ID: 19579725
That is a very complex connection string. Here is one that works:
"Password=pwd;User ID=me;Data Source=SID;Persist Security Info=False;Pooling=true;min pool size=1; max pool size=100; statement cache size=200"

This one just uses the SID to make use of the descriptor in tnsnames. It looks like yours is possibly substituting for the tnsnames entry. I would suggest that you try the simple one to verify that it works for you. If it does, you can try changing it bit by bit until it resembles yours, if you want that structure.
0
 
LVL 14

Expert Comment

by:sathyagiri
ID: 19579764
Edit your sqlnet.ora and modify the sql net.authentication_services entry to

Modified Entry - SQLNET.AUTHENTICATION_SERVICES= (NONE
0
 
LVL 14

Accepted Solution

by:
sathyagiri earned 2000 total points
ID: 19579783
Should be SQLNET.AUTHENTICATION_SERVICES= (NONE)
0
 
LVL 15

Author Comment

by:Solar_Flare
ID: 19588982
thanks guys, but the problem is not the connection string or the sqlnet.ora file as it works fine from the VB.net app (I also dont want to rely on oracle being set up on the client machine for this to work).

turns out it just needed a restart of the VS development web server and the connection worked again. something buggy in the microsoft oracleclient? anyway, it seems to be working.
0
 
LVL 15

Author Comment

by:Solar_Flare
ID: 19614375
after more intermittant authorization issues I found that sathygiri's suggestion helped a lot, so will awards points for that.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question