Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Connect Oracle in ASP.NET Without Oracle drivers

Posted on 2008-10-07
4
Medium Priority
?
1,415 Views
Last Modified: 2012-05-05
My boss asked me to change this class to connect to the oracle database without the oracle drivers.
I need to do the connection, i think this is possible
i attach the code so u can see and give me a hint
note. i don't know much about C# but i appreciate any help

TIA
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using OlapSaleManager.Entity.dba;
using System.Data.OleDb;
 
namespace OlapSaleManager.Services
{
    public class ProcessService
    {
        public static void startProcess(String connectionString)
        {
            List<Job> jobs = ProcessService.liveJobs(connectionString);
 
            // Si no tiene jobs levanto
            if (jobs.Count == 0)
            {
                // Crea conexion
                OleDbConnection remoteConnection = new OleDbConnection(connectionString);
 
                // Abre conexion
                remoteConnection.Open();
 
                // Crea Comando
                OleDbCommand cmdSelectJobs = remoteConnection.CreateCommand();
                cmdSelectJobs.CommandText = "BEGIN  proventacs.olap_sales.start_system;end;";
 
                // Ejecuta comando
                cmdSelectJobs.ExecuteNonQuery();
                
                // Finaliza
                remoteConnection.Close();
            }
 
        }
 
        public static void killJob(String connectionString,String jobNumber)
        {
            // Crea conexion
            OleDbConnection remoteConnection = new OleDbConnection(connectionString);
 
            // Abre conexion
            remoteConnection.Open();
 
            // Crea Comando
            OleDbCommand killJob = remoteConnection.CreateCommand();
            killJob.CommandText = "BEGIN dbms_job.broken(" + jobNumber + ", TRUE);dbms_job.remove(" + jobNumber + ");end;";
 
            // Ejecuta comando
            killJob.ExecuteNonQuery();
 
            // Finaliza
            remoteConnection.Close();
        }
        public static void stopProcess(String connectionString)
        {
            List<Job> jobs = ProcessService.liveJobs(connectionString);
 
            // Si no tiene jobs levanto
            if (jobs.Count > 0)
            {
                // Crea conexion
                OleDbConnection remoteConnection = new OleDbConnection(connectionString);
 
                // Abre conexion
                remoteConnection.Open();
 
                // Crea Comando
                OleDbCommand cmdSelectJobs = remoteConnection.CreateCommand();
                cmdSelectJobs.CommandText = "BEGIN proventacs.olap_sales.stop_system;end;";
 
                // Ejecuta comando
                cmdSelectJobs.ExecuteNonQuery();
 
                // Finaliza
                remoteConnection.Close();
            }
        }
 
        public static List<Job> liveJobs(String connectionString)
        {
            List<Job> jobs = new List<Job>();
 
            OleDbConnection remoteConnection = new OleDbConnection(connectionString);
 
            remoteConnection.Open();
 
            OleDbCommand cmdSelectJobs = remoteConnection.CreateCommand();
            cmdSelectJobs.CommandText = "SELECT * FROM DBA_JOBS";
 
            OleDbDataReader drJobs = cmdSelectJobs.ExecuteReader();
 
            while (drJobs.Read())
            {
                jobs.Add( new Job(
                    System.Convert.ToInt32( drJobs[0].ToString()),
                    drJobs[1].ToString(),
                    drJobs[3].ToString(),
                    drJobs[4].ToString(),
                    drJobs[5].ToString(),
                    drJobs[6].ToString(),
                    drJobs[7].ToString(),
                    drJobs[8].ToString(),
                    drJobs[9].ToString(),
                    System.Convert.ToInt32( drJobs[10]).ToString(),
                    drJobs[11].ToString(),
                    drJobs[12].ToString(),
                    drJobs[14].ToString()
                    ));
 
 
            }
            drJobs.Close();
 
            remoteConnection.Close();
 
            return jobs;
        }
    }
}

Open in new window

0
Comment
Question by:ShinyDarkStone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
gemailj earned 1000 total points
ID: 22666043
i think that there is oracle .net driver that allow you to connect directly to the oracle DB

http://www.microsoft.com/downloads/details.aspx?FamilyID=4F55D429-17DC-45EA-BFB3-076D1C052524&displaylang=en
this is .NET Managed Provider for Oracle

http://www.4guysfromrolla.com/webtech/tips/t080902-1.shtml
this is User Tips: Using the .NET Framework Data Provider for Oracle
0
 
LVL 1

Author Comment

by:ShinyDarkStone
ID: 22666394
no, i was thinking something with odbc instead oledb
but like i said, i don't know much about c# neither how to port the oledb methods to odbc.
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 22672794
>no, i was thinking something with odbc instead oledb
why go back in time? oledb is better than odbc, especially supporting the newer features and larger data types...

>My boss asked me to change this class to connect to the oracle database without the oracle drivers.
you CANNOT connect to oracle without the oracle drivers (ie the oracle client).
the oracle part can be very small though: instant client:
www.oracle.com/technology/tech/oci/instantclient/index.html

>using System.Data.OleDb;
this part is contained in the .net framework, so nothing more is needed. just the right connection string
0
 
LVL 1

Author Comment

by:ShinyDarkStone
ID: 22673235
tnx, i solved it, but now, im having trouble, when i try to send the method it hangs on the remoteconnection.open() says "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified" i set up the conection string, but it still shows that message.
i know there is something missing, but i cant figure out what
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

670 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