Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2003, 09:36 AM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecting to Oracle 9i through ADO.NET

Hi,

I need to connect to an Oracle 9i Database from ASP.NET. Although I can connect to the Oracle Database through SQL*Plus using the same userid/password and service name.

I have downloaded and installed the latest Oracle ODBC drivers for 9.01 from Oracle's website and it didnt help. Also I installed Microsoft .NET Oracle Client and it produced the same results.


I have included the following namespaces and am using the following connection string to connect to Oracle -


<%@ Page Language="VB" Debug="true" Trace="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDB" %>

szConStr = "Provider=OraOLEDB.Oracle;Data Source=abc; User ID=xyz; Password=xyz123;"


In ASP.NET however I get the following error -

ORA-12154: TNS:could not resolve service name

Stack Trace:


[OleDbException (0x80004005): ORA-12154: TNS:could not resolve service name]
   System.Data.OleDb.OleDbConnection.ProcessResults(I nt32 hr) +20
   System.Data.OleDb.OleDbConnection.InitializeProvid er() +57
   System.Data.OleDb.OleDbConnection.Open() +203
   ASP.G3_ASPX.Page_Load(Object Sender, EventArgs E) in D:\timesheet\ts04\g3.aspx:50
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +725

What could be wrong. Please suggest. Thanks.

 
Old July 10th, 2003, 02:54 AM
Registered User
 
Join Date: Jun 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to samlow82 Send a message via Yahoo to samlow82
Default

I'm using vb with Oracle.
In Global.asax:
Session("ELTS") = OleDbConnection1

In Webform:
Imports System.Data.OleDb
Dim ELTS As OleDbConnection

In Page_Load:
Dim connection As New OleDb.OleDbConnection()
connection.ConnectionString = "Provider=MSDAORA.1;Password=fme9elts;User ID=mp_elts;Data Source=fme9;"
connection.Open()
 
Old August 26th, 2003, 06:56 PM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure if this was the fastest solution, but here it is:
- I had Oracle 8 and 9 clients, so I removed both and installed Oracle 9 client
- Downloaded Microsoft .NET Managed Provider for Oracle at http://www.microsoft.com/downloads/d...displaylang=en
- Switched my code to use System.Data.OracleClient

Example:
        Dim cmd As System.Data.OracleClient.OracleCommand
        Dim con As New System.Data.OracleClient.OracleConnection()
        con.ConnectionString = "Password=test;User ID=test;Data Source=service.domain.com;" 'domain.com is optional if it is default in sqlnet.ora
        con.Open()
        cmd = con.CreateCommand()
        cmd.CommandText = "select report_desc from report"
        cmd.CommandType = CommandType.Text
        Dim rs As System.Data.OracleClient.OracleDataReader
        rs = cmd.ExecuteReader
        ListBox1.Items.Clear()
        Do While rs.Read
            ListBox1.Items.Add(CType(rs(0), String))
        Loop
        'Do not forget to close, big problems later
        rs.Close()








Similar Threads
Thread Thread Starter Forum Replies Last Post
Bulk Insert in Oracle 9i from Classic ASP (ADO) rupen Classic ASP Databases 0 January 11th, 2008 07:49 AM
insert/retrive image from oracle 9i in asp.net 2.0 Pramod2005 .NET Framework 1.x 0 July 4th, 2007 02:55 AM
Error While Connecting to Oracle 9i via .Net soft4net ADO.NET 1 December 21st, 2006 03:14 AM
How to run ASP.Net with Oracle 9i ramk_1978 ASP.NET 1.0 and 1.1 Professional 1 September 7th, 2006 08:07 PM
connecting asp.net to oracle farsfar2 ASP.NET 1.0 and 1.1 Basics 1 January 1st, 2006 04:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.