70 pts.
 What am I doing wrong. Please Help
An unhandled exception of type 'Oracle.DataAccess.Client.OracleException' occurred in oracle.dataaccess.dll Additional information: System error. Imports System.Data Imports Oracle.DataAccess.Client Public Class Form1 Inherits System.Windows.Forms.Form Dim objConnection As OracleConnection = New _ OracleConnection("User Id=system;Password=dax856;Data Source=DMS") Dim objDataAdapter As New OracleDataAdapter Dim objDataSet As DataSet = New DataSet Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Set the SelectCommand properties... objDataAdapter.SelectCommand = New OracleCommand objDataAdapter.SelectCommand.Connection = objConnection objDataAdapter.SelectCommand.CommandText = _ "Select * From EMP" objDataAdapter.SelectCommand.CommandType = CommandType.Text ' open the data base objConnection.Open() Please note using Tools for the menu I can connect to the Data Base selecting Connect To Data Base But failed if I choose the option Connect To Oracle Data Base Regards

Software/Hardware used:
ASKED: March 9, 2009  1:45 PM
UPDATED: March 10, 2009  12:25 AM

Answer Wiki:
Have you installed the Oracle client software in adittion to the ODP.NET (Oracle Data Provider for .NET) ? Can you connect from SQL*Plus ? Have a look at the following page: <a href="http://www.oracle.com/technology/pub/articles/cook_dotnet.html">http://www.oracle.com/technology/pub/articles/cook_dotnet.html</a>
Last Wiki Answer Submitted:  March 9, 2009  4:47 pm  by  carlosdl   63,580 pts.
All Answer Wiki Contributors:  carlosdl   63,580 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Hi Carlosdl. Thanks for responding.
I can connect form SQL.
It fails at line objConnection.Open()

In .Net from the Tools menu I can connect using the Connect To Data Base option.
If I try the option Connect To Oracle Data Base again from the Tools menu it fail to connect.

Regards

 70 pts.

 

‘DefaultDomain’: Loaded ‘c:windowsmicrosoft.netframeworkv1.1.4322mscorlib.dll’, No symbols loaded.
‘DataSetExample’: Loaded ‘C:Net2003projectsDataSetExamplebinDataSetExample.exe’, Symbols loaded.
‘DataSetExample.exe’: Loaded ‘c:windowsassemblygacsystem.windows.forms1.0.5000.0__b77a5c561934e089system.windows.forms.dll’, No symbols loaded.
‘DataSetExample.exe’: Loaded ‘c:windowsassemblygacsystem1.0.5000.0__b77a5c561934e089system.dll’, No symbols loaded.
‘DataSetExample.exe’: Loaded ‘c:windowsassemblygacoracle.dataaccess10.1.0.400__89b483f429c47342oracle.dataaccess.dll’, No symbols loaded.
‘DataSetExample.exe’: Loaded ‘c:windowsassemblygacsystem.data1.0.5000.0__b77a5c561934e089system.data.dll’, No symbols loaded.
‘DataSetExample.exe’: Loaded ‘c:windowsassemblygacsystem.xml1.0.5000.0__b77a5c561934e089system.xml.dll’, No symbols loaded.
‘DataSetExample.exe’: Loaded ‘c:windowsassemblygacsystem.drawing1.0.5000.0__b03f5f7f11d50a3asystem.drawing.dll’, No symbols loaded.
‘DataSetExample.exe’: Loaded ‘c:windowsassemblygacsystem.enterpriseservices1.0.5000.0__b03f5f7f11d50a3asystem.enterpriseservices.dll’, No symbols loaded.
‘DataSetExample.exe’: Loaded ‘c:windowsassemblygacsystem.enterpriseservices1.0.5000.0__b03f5f7f11d50a3asystem.enterpriseservices.thunk.dll’, No symbols loaded.
An unhandled exception of type ‘Oracle.DataAccess.Client.OracleException’ occurred in oracle.dataaccess.dll

Additional information: System error.

Unhandled Exception: Oracle.DataAccess.Client.OracleException ORA-12154: TNS:could not resolve the connect identifier specified at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at DataSetExample.Form1.Form1_Load(Object sender, EventArgs e) in C:Net2003projectsDataSetExampleForm1.vb:line 85
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at DataSetExample.Form1.Main() in C:Net2003projectsDataSetExampleForm1.vb:line 5The program ‘[1720] DataSetExample.exe’ has exited with code 0 (0×0).

 70 pts.

 

The problem seems to be that you are using a database alias that is not defined in your tnsnames.ora file.

If you can connect from SQL*Plus, then I guess you have two different Oracle clients installed. The first thing to check would be the existence of more than 1 tnsnames.ora files.

The correct tnsnames.ora file should have an entry for DMS in it.

Something similar to this:

DMS=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=TCP)(HOST=OTNSRVR)(PORT=1521))
    )
    (CONNECT_DATA=
      (SERVER=DEDICATED)
      (SERVICE_NAME=ORCL)
    )
  )

If you find more than one tnsnames file, you will need to copy the one that has the above definition for DMS to the location where the other file was found, because that is the Oracle client your program/IDE is using.

Please check that, and post back with the results.

 63,580 pts.