Solved

DB Access

Posted on 2015-01-18
7
65 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 500 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
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
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: …

623 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