• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

Connecting to Oracle in Vs.net 2005

So all i'm trying to do is query an oracle DB from vs.net.  I get a slew of error messages depending on the connection string/driver/prodiver i use.
What gets me is that i can ping the server, tsnping, connect through Data Sources(ODBC), and Oracle's 'SQL Developer' tool but I can't using Vs.
My latest effort has me at
Dim oSQLConn As New OleDb.OleDbConnection
oSQLConn.ConnectionString = "Provider=OraOLEDB.Oracle;{DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=DEV.X.X)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ARC)(SID=ARC.X.X)))"
oSQLConn.Open()
Which gives me "ORA-12560: TNS:protocol adapter error"
That connection string was taken straight out of the tnsnames.ora created by Sql developer.
Please keep in mind I'm a novice at anything oracle.
0
cvoutour
Asked:
cvoutour
  • 3
  • 2
2 Solutions
 
Bob LearnedCommented:
If you have the tnsnames.ora, then you could use the simple form of the connection string, and the System.Data.OracleClient namespace:

Oracle connection strings:
http://www.connectionstrings.com/?carrier=oracle

Data Source=MyOracleDB;Integrated Security=yes;


Imports System.Data.OracleClient
 
...
 
Public Function GetReceivedDateCount() As Integer
 
Dim connectionString As String = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString
 
Using connection As New OracleConnection(connectionString))
   connection.Open()
   Dim commandText As String = "Select Count(Received_Date) As CountDates From Receiving"
   Using command As New OracleCommand(commandText, connection)
        Dim countDates As Integer = command.ExecuteScalar()
        Return countDates
   End Using
End Using
 
End Function

Open in new window

0
 
cvoutourAuthor Commented:
I don't have a 'system.data.oracleclient' namespace available.
i've been to the connectionstrings.com site many times, tried every example there.
0
 
cvoutourAuthor Commented:
Correction: I have the system.data.oracleclient namespace, i just get an error on
Dim connectionString As String = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString
0
 
Bob LearnedCommented:
That was just an example of getting a connection string from a configuration file.  You would need to add a reference to the System.Configuration.dll, and a Imports System.Configuration to your project and code module.

Bob
0
 
cvoutourAuthor Commented:
I had to tweak it a bit, replacing the connectionString with the info i had listed above, but the system.data.oracleclient namespace seems to be what i needed.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now