Solved

Connect to Oracle database in C# ASP

Posted on 2007-03-20
10
1,304 Views
Last Modified: 2013-12-19
Please help me in connecting to Oracle via a VPN connection.
My database is located on my school's server.  I can connect to it using the following parameters:
    * Name: apollo.ite.gmu.edu
    * Port: 1521
    * Oracle SID: ite10g

 As long as I'm on the school network I can connect.  But I am not sure how to add these parameters for my ASP page.  Thank you,
0
Comment
Question by:adajani1
  • 3
  • 2
  • 2
10 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 18758284
What data provider are you wanting to use?  I suggest ODP.Net which is Oracle's .Net data provider but some people like OLEDB and use either Oracle's or Microsofts.

Once you have the dataprovider installed you'll just need the proper references.

There's a decent page that has just about ever type of connection string available:
http://www.carlprothman.net/Default.aspx?tabid=81
0
 

Author Comment

by:adajani1
ID: 18758403
MY *.asp page will be on the school's network.

I was only provided with the above parameters.   Not sure what driver they installed.
0
 

Author Comment

by:adajani1
ID: 18758428
I did an application with java b4 using the following parameters and it worked.. I just don't know how to include this info for my ASP.


String driverName = "oracle.jdbc.driver.OracleDriver";
       Class.forName(driverName);

       System.out.println("Connecting   to Oracle...");  

       String url = "jdbc:oracle:thin:@apollo.ite.gmu.edu:1521:ite10g";
       Connection conn = DriverManager.getConnection(url,"name","password");



0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 250 total points
ID: 18758896
It's very similar in .Net to the Java connection you posted.

I would guess the Microsoft OLEDB for Oracle driver.

Take a look at:
http://www.carlprothman.net/Default.aspx?tabid=87#OLEDBProviderForOracleFromMicrosoft

If you're still unsure, here's a simple .Net page using VB.Net and ODP.Net.  Hopefully it will give you a starting place.
-----------------------------------------------------------
<%@ import namespace = "System.Data" %>
<%@ import namespace = "System.XML" %>
<%@ import namespace = "Oracle.DataAccess.Client" %>
<%@ import namespace = "Oracle.DataAccess.Types" %>

<html>
<title>simple DB test</title>
<body>

<script language="VB" runat="server">


sub page_load(sender as object,e as eventargs)

      Dim con As New OracleConnection("User Id=<user>;Password=<pass>;Data Source=<DBAlias>;")

      Dim cmd as OracleCommand = new OracleCommand()
      cmd.Connection      = con
      cmd.CommandType      = CommandType.Text
      cmd.commandText      = " select  sysdate from dual "

      try
            con.open()

            response.write("<br/>Got: " &  cmd.executeScalar())

      catch ex as exception
            
            response.write("Error: " & ex.message)

      finally
            con.close()
            cmd.Dispose()
      end try
end sub
</script>

</body>
</html>


0
 
LVL 4

Assisted Solution

by:ramumorla
ramumorla earned 250 total points
ID: 18876566
This is a common problem on VPN connections

Try to  ping your server with FQDN (ping apollo.ite.gmu.edu) 99.99% the ping will fail
then if it fails, learn the ip address of the oracle server from ur admin and replace apollo.ite.gmu.edu
 with the ip address.

Your problem is solved-- Very simple
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 19042276
I suggest a split between ramumorla and myself.
0
 
LVL 4

Expert Comment

by:ramumorla
ID: 19069820
i agree
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Syntax error 9 45
Word Directory is not in the drop down list 4 25
C# Json POSt to Rest API 4 37
How would you add MULTITHREADING to the attached C# code? 4 51
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Via a live example, show how to take different types of Oracle backups using RMAN.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now