Question

I have put my tns connection into the .ora file and am now able to conenct to it using SQL plus and can ping it :tnsping myConn.

I've also added the connection to the ODBC Manager and connecting successfully when tetsing conneciton through the ODBC tool.

now i'm having an issue making a connection to it using vb.net

i've tried the following:

  oODBCConnection = New Odbc.OdbcConnection(connStr)
            oODBCConnection.Open()

where my connStr is:

Data Source=tns.dev;User Id=MyUser;Password=MyPass;

per: http://www.connectionstrings.com/oracle and http://www.shabdar.org/c-sharp/101-connect-to-oracle-using-asp-net-and-csharp.html

what am i doing wrong? it's telling me i need to specify a driver, how do i do it?

Thank you!

the error i'm getting is:

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Was it helpful?

Solution 3

ODBCConnection was incorrect.

solution:

 Dim myConnection As OleDbConnection
    Dim myCommand As OleDbCommand
  Dim myConnection As New OracleConnection(connStr)
            myConnection.Open()

OTHER TIPS

Did you checked the tnsnames.ora file? Is there any entry for tns.dev?

http://www.mike-devlin.com/oracle/tnsnames_ora.htm

That is not an oracle error - it sounds like you did not create a system dsn. This code looks like it expects a DSN by name of tns.dev.

That said, I would not use odbc if I could help it. You might want to look at Oracle Data Provider for .net

http://www.oracle.com/technetwork/topics/dotnet/index-085163.html

I´ve been using the following code in Vb.net

Dim conn As New Odbc.OdbcConnection
Dim cmd As New Odbc.OdbcCommand
Dim drResult As Odbc.OdbcDataReader
Dim connString As String
Dim QuerySQL As String

connString = "Driver={Microsoft ODBC for Oracle};CONNECTSTRING=(DESCRIPTION=(ADDRESS=  (PROTOCOL=TCP)(HOST=ORACLEDB01)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORACLE_INSTANCE_NAME)));Uid=john;Pwd=mypassword;"
QuerySQL = "select first_name, last_name from employees where id = 28"

conn.ConnectionString = connString
conn.Open()
cmd.Connection = conn
cmd.CommandText = QuerySQL
drResult = cmd.ExecuteReader()

While drResult.Read
  TextBox1.Text = TextBox1.Text & drResult("last_name") & ", " & drResult("first_name") & Environment.Newline
End While
drResult.Close()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top