Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Visual Studio 2010 connect to oracle with odp.net

Steve42Feb 25 2013 — edited Feb 25 2013
I have a simple form in Visual Studio 2010 that connects to Oracle database. And it WORKS.

Im using Windows XP and the Oracle is on a remote window server. However when I try to Add a data connection to the project: I get either:

ORA-12560: TNS:protocol adapter error.( If I leave the source as Local Database)

ORA-12154: TNS:could not resolve the connect identifier specified ( If I change datasource to "jerry_apps"- which is what it is called in tnsnames.ora)

I copied the tnsnames.ora into the different directories to keep it the same. I even configured an "Oracle Listner".

However I cannot get a connection of the database to the project.

====== Code below WORKS ===
<code>
Dim oradb As String = "Data Source=" _
+ "(DESCRIPTION =" _
+ " (ADDRESS_LIST = " _
+ " (ADDRESS = (PROTOCOL = TCP)(HOST = jerry.ces.uaex.edu)(PORT = 1521)) " _
+ " ) " _
+ " (CONNECT_DATA = " _
+ " (SERVICE_NAME = APPS)" _
+ " ) " _
+ " );User Id=accountt;Password=my_pwd; "

Dim conn As New OracleConnection(oradb)
conn.Open()
Dim cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "select cit2 from wild9 where zipl=72055"
cmd.CommandType = CommandType.Text
Dim dr As OracleDataReader = cmd.ExecuteReader()
dr.Read()
Label1.Text = dr.Item("cit2")
conn.Dispose()
</code>


Any suggestions?

TIA
Steve42
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2013
Added on Feb 25 2013
1 comment
2,684 views