0

At the moment I'm trying to make a connection to a local server. Connecting via, say, TOAD works fine. When I try to connect using .NET I get ora-12154. Which puzzles me, since I'm using the connectionstring from my TNSNAMES.ora file:

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = myPC)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

As follows:

private string connectionString = "Data Source=(DESCRIPTION ="
    +"    (ADDRESS_LIST=(ADDRESS = (PROTOCOL = TCP)(HOST = myPC)(PORT = 1521)))"
    +"    (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = XE));"
    +"User Id=sys;Password=zsxyzabc;";

Any ideas?

3 Answers 3

1

You are connecting as SYS. Therefor you need to include the SYSDBA privilege:

+"User Id=sys;Password=zsxyzabc;DBA Privilege=SYSDBA;";

It is bad practice to use the SYS account for regular application work, or even regular DBA work. But it is necessary sometimes, and when it is necessary we have to connect as sysdba.

edit

It is a subtle one: you have a missing bracket at the end of the string!

private string connectionString = "Data Source=(DESCRIPTION =" 
    +"    (ADDRESS_LIST=(ADDRESS = (PROTOCOL = TCP)(HOST = myPC)(PORT = 1521)))" 
    +"    (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = XE)));" 
                                                                  ^

Having an IDE with bracket matching (I use TextPad) is a boon in these cases.

Sign up to request clarification or add additional context in comments.

2 Comments

I tried logging in as a 'normal' user as well, with the same result.
Oh dear... VS doesn't show missing brackets in string, so I completely overlooked it. Thank you for being sharp ;)
0

This is a great site for sorting out your connection string issues:

www.connectionstrings.com

1 Comment

The connectionstring is straight from the tnsnames file
0

You may only be able to do this with the Oracle's .NET provider. That provider does support a "DBA Privilege=SYSDBA" setting in your connection string.

Why are you login with SYS user? It's dangerous, you may create a new user and connect with it. You may want to give any privileges you want. Try also this one :

string connString = "User Id=sys; Password=zsxyzabc; Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myPC)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SID=xe)))";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.