Tech Junkie Blog - Real World Tutorials, Happy Coding!: C# Querying From An Oracle Database

Thursday, September 5, 2013

C# Querying From An Oracle Database

In this blog we will go over how to query an Oracle database in ASP.NET using the System.Data.OracleClient data provider in C#.

Namespaces:

using System.Web.Configuration;
using System.Data.OracleClient;
using System.Data;

            string cs = WebConfigurationManager.ConnectionStrings["SomeConnectionString"].ConnectionString;

            using (OracleConnection oc = new OracleConnection(cs))
            {
                oc.Open();
                DataTable dt = new DataTable(); 
                OracleCommand ocmd = new OracleCommand("SELECT * FROM SOMETABLE", oc);
                OracleDataAdapter oda = new OracleDataAdapter(ocmd);

                oda.Fill(dt);

                GridView1.DataSource = dt;
                GridView1.DataBind();

            }
Previous: Oracle Date Format And Compare

3 comments:


  1. When searching for reliable printing solutions, many people look for convenient options in their area. If you're interested in finding services quickly, you might want to explore local providers. You can easily find more information about options available by checking out dtf transfers near me. This way, you can ensure a smooth and efficient process without unnecessary delays.

    ReplyDelete

Search This Blog