Solved

DB Access

Posted on 2015-01-18
7
58 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
  • 4
  • 3
7 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
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
Comment Utility
How about update like this?

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

This is a little different.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
That's an ExecuteNonQuery call instead of an ExecuteReader call.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

by:minglelinch
Comment Utility
So it is exactly like dealing with SQL Server DB ... ?
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
Thank you.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

7 Experts available now in Live!

Get 1:1 Help Now