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

x
?
Solved

DB Access

Posted on 2015-01-18
7
Medium Priority
?
66 Views
Last Modified: 2015-01-18
I'm working on a .net/C# web application. I do not use entity framework. I use ODP.Net to connect to the Oracle db.

I used SQL Server before. For query statement, and it has different calls for queries like select, update or single value select. How about Oracle?  If I assign SQL statement to command insteaf of store procedure, what would be the code ?

 Thanks.
0
Comment
Question by:minglelinch
[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
  • 4
  • 3
7 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 40556534
It's more or less the same exact code; you just change the command type.

e.g.

using (OracleConnection connection = new OracleConnection("connection string"))
{
    using (OracleCommand cmd = new OracleCommand("SELECT * FROM DUAL", connection))
    {
        cmd.CommandType = CommandType.Text;
        connection.Open();
        OracleDataReader reader = cmd.ExecuteReader();

        if (reader.Read())
        {
            // do something with data
        }
    }
}

Open in new window

0
 
LVL 1

Author Comment

by:minglelinch
ID: 40556541
How about update like this?

update emp
set empName = 'namestrong'
where empid = 1

This is a little different.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40556551
That's an ExecuteNonQuery call instead of an ExecuteReader call.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 1

Author Comment

by:minglelinch
ID: 40556565
So it is exactly like dealing with SQL Server DB ... ?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40556575
Yep. All of the data access libraries that I've seen for connecting with various DBMS (and others) follow that same pattern--as far as .NET. Libraries typically implement the classes and interfaces found under the System.Data namespace, so you have some guarantee of what methods you have available to you.
0
 
LVL 1

Author Closing Comment

by:minglelinch
ID: 40556579
Thank you.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40556584
The only thing I'll add is that where you'll run into differences are when you use things that are specific to that DBMS. Things like user-defined types and arrays get handled slightly differently with the Oracle stuff.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

722 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