473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

is it possible to access an Oracle db in .net

this may seem a trivial question (as .net may have been solely developed for
this purpose),
but i'm not certain whether this is possible,

i.e. is it possible to access an Oracle DB in .NET (and is it the same as
accessing any other db - except for the connection string & object).
What is mean is, can i use the same select statements, update statements
with the orable database that i used with MSDE & SQL database?

thank u all
Nov 21 '05 #1
5 2054
rs
http://msdn.microsoft.com/library/de...ClassTopic.asp
"Amueerie" <a_*******@msn.com> wrote in message
news:u%****************@TK2MSFTNGP10.phx.gbl...
this may seem a trivial question (as .net may have been solely developed
for
this purpose),
but i'm not certain whether this is possible,

i.e. is it possible to access an Oracle DB in .NET (and is it the same as
accessing any other db - except for the connection string & object).
What is mean is, can i use the same select statements, update statements
with the orable database that i used with MSDE & SQL database?

thank u all

Nov 21 '05 #2
Bob
Hi,
Yes,
Change your declaration of the data access variables to the oracle flavour.
Following snippet shows using a compiler directive to control which database
this routine is looking at.
Oracle have OMWB (Oracle migration workbench) which will do a passable job
of converting an SQL Server database to an Oracle one.
The caveat being that you will have to massage the stored procedures to get
them to work.
If you go this way then suggest a copy of TOAD as it takes away the pain
when working with Oracle schemas.
Note: that you need a a cursor output parameter to get data back with an
Oracle SPROC. ( You'll see this below)
HTH
Bob
#If Not Oracle Then

Dim cmdConn As New SqlClient.SqlCommand

Dim cmdSource As SqlClient.SqlDataReader

Try

cmdConn = New SqlClient.SqlCommand(strSQL, New
SqlClient.SqlConnection(mstrConn))

strSQL = "exec proc_GetContact @contact_id"

cmdConn.Parameters.Add(New SqlParameter("@contact_id", SqlDbType.Int))

cmdConn.Parameters("@contact_id").Value = intContactID

cmdConn.CommandText = strSQL

cmdConn.Connection.Open()

cmdSource = cmdConn.ExecuteReader(CommandBehavior.CloseConnect ion)

'End If

If cmdSource.Read Then

C.ID = cmdSource.GetSqlInt32(0).Value

If Not cmdSource.GetSqlString(1).IsNull Then C.Firstname =
cmdSource.GetSqlString(1).Value

If Not cmdSource.GetSqlString(2).IsNull Then C.Surname =
cmdSource.GetSqlString(2).Value

If Not cmdSource.GetSqlString(3).IsNull Then C.EmailAddress =
cmdSource.GetSqlString(3).Value

If Not cmdSource.GetSqlString(4).IsNull Then C.SMSAddress =
cmdSource.GetSqlString(4).Value

If Not cmdSource.GetSqlString(5).IsNull Then C.Phone =
cmdSource.GetSqlString(5).Value

If Not cmdSource.GetSqlString(6).IsNull Then C.FAX =
cmdSource.GetSqlString(6).Value

Return True

End If

Catch obja As System.Exception

WriteErrorLog("DT.GetContactList Error " & obja.Message)

Finally

cmdSource.Close()

cmdConn.Dispose()

End Try

#Else

Dim cmdConn As OracleClient.OracleCommand

Dim cmdSource As OracleClient.OracleDataReader

Try

strSQL = "proc_GetContact"

cmdConn = New OracleClient.OracleCommand(strSQL, New
OracleClient.OracleConnection(mstrConn))

cmdConn.Parameters.Add(New OracleParameter("contact_id", OracleType.Number,
0, ParameterDirection.Input, _

True, 0, 0, "", DataRowVersion.Default, mydbNull))

cmdConn.Parameters.Add(New OracleClient.OracleParameter("o_cursor",
OracleClient.OracleType.Cursor, _

2000, ParameterDirection.Output, True, 0, 0, "", DataRowVersion.Default,
mydbNull))

cmdConn.CommandType = CommandType.StoredProcedure

cmdConn.Parameters("contact_id").Value = intContactID

cmdConn.Connection.Open()

cmdSource = cmdConn.ExecuteReader(CommandBehavior.CloseConnect ion)

'End If

If cmdSource.Read Then

C.ID = CInt(cmdSource.GetOracleNumber(0).Value)

If Not cmdSource.GetOracleString(1).IsNull Then C.Firstname =
cmdSource.GetOracleString(1).Value

If Not cmdSource.GetOracleString(2).IsNull Then C.Surname =
cmdSource.GetOracleString(2).Value

If Not cmdSource.GetOracleString(3).IsNull Then C.EmailAddress =
cmdSource.GetOracleString(3).Value

If Not cmdSource.GetOracleString(4).IsNull Then C.SMSAddress =
cmdSource.GetOracleString(4).Value

If Not cmdSource.GetOracleString(5).IsNull Then C.Phone =
cmdSource.GetOracleString(5).Value

If Not cmdSource.GetOracleString(6).IsNull Then C.FAX =
cmdSource.GetOracleString(6).Value

Return True

End If

Catch obja As System.Exception

WriteErrorLog("DT.GetContactList Error " & obja.Message)

Finally

cmdSource.Dispose()

If cmdConn.Connection.State <> ConnectionState.Closed Then

cmdConn.Connection.Close()

End If

cmdConn.Dispose()

End Try

#End If
"Amueerie" <a_*******@msn.com> wrote in message
news:u%****************@TK2MSFTNGP10.phx.gbl...
this may seem a trivial question (as .net may have been solely developed for this purpose),
but i'm not certain whether this is possible,

i.e. is it possible to access an Oracle DB in .NET (and is it the same as
accessing any other db - except for the connection string & object).
What is mean is, can i use the same select statements, update statements
with the orable database that i used with MSDE & SQL database?

thank u all

Nov 21 '05 #3
Amueerie,

You can use OleDB for almost everything, however it is not clever.
There are 3 main base classes which acts (almost) the same
SQLClient for SQL Server
OracleClient for Oracle
OleDb for the rest

In my opinion is it better to create seperate classes for the database
handling for those or integrate in your classes for that the different
types.

Just my thought,

Cor
Nov 21 '05 #4
"Amueerie" <a_*******@msn.com> schrieb:
i.e. is it possible to access an Oracle DB in .NET (and is it the same as
accessing any other db - except for the connection string & object).
What is mean is, can i use the same select statements, update statements
with the orable database that i used with MSDE & SQL database?


..NET Framework Developer's Guide -- .NET Framework Data Providers
<URL:http://msdn.microsoft.com/library/en-us/cpguide/html/cpconADONETProviders.asp>

<URL:http://support.microsoft.com/search/?catalog=LCID%3D1033&query=Oracle+.NET>

<URL:http://www.connectionstrings.com/>
-> "Oracle"

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
> i.e. is it possible to access an Oracle DB in .NET (and is it the same as
accessing any other db - except for the connection string & object).
The objects are not exactly the same, they are OraXXX objects. The only way
to use portable objects is to use the underlying IdbXXX interfaces that
implement the objects.
What is mean is, can i use the same select statements, update statements
with the orable database that i used with MSDE & SQL database?


Surely not. MSDE and SQL Server uses Transact SQL while Oracle uses PL/SQL.
That means that SQL statements can vary slightly. The industry has done 2
attempts to solve this problem:

- Make vendors to be compliant with ANSI SQL. The conformance level is
increasingly better, but you have to verify your SQL statements.
- Microsoft provided neutral ODBC syntax which at least ODBC drivers and
OLEDB providers support, not sure about .NET Data Providers.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sedefo | last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i was researching how i can write a database independent data access layer. In my company we already use Data Access...
3
by: Jon Ole Hedne | last post by:
My Access 2002-application need to work with tables from both Oracle and Access. To solve this, I want to run some querys on three views in Oracle and import the results into temporary...
10
by: Andrea M. Segovia | last post by:
Hello, I am a newbie to Oracle databases.... We have a visualization front-end tool connected to an Oracle back-end database on a Tru64 UNIX server. We also have clients with MS access...
13
by: BigDaDDY | last post by:
Um yeah....In case you haven't figured it out, Microsoft sucks. I'm going to be kicked back in my chair eating popcorn and watching football 10 years from now, while all you clowns are scrambling...
1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
11
by: Rosco | last post by:
Does anyone have a good URL or info whre Oracle and Access are compared to one another in performance, security, cost etc. Before you jump on me I know Oracle is a Cadillac compared to Access the...
6
by: M. Schroeder | last post by:
I use an Access-form to write into an external Oracle table via Oracle-ODBC driver. It is not a read-only connection, and batch autocommit mode set to "all successful statements". I can read...
2
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with...
8
by: Lykins | last post by:
We currently use Access 2003 in our company and have had this issues from every version from Access 97 to 2003. We deal with large databases and run a lot of queries over tables with millions of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.