Retrieving data from Oracle database

492 views Asked by At

I am trying to retrieve data from Oracle database and display it in ASP.net Grid. Have tried using the execute reader and the data adapter options as listed below, have succeeded in establishing the connection but no luck with data retrieval.

It does not retrieve the data at all, have done with ease in SQL but here it is taking whole lot of time with no luck.

Code snippets used:

using execute reader

OracleConnection conn = new OracleConnection();
            conn.ConnectionString = "user id=xxx;password=xxx;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xxxx)(PORT=xxxx))(CONNECT_DATA=(SERVICE_NAME=xxxxx)));";

            //"+"Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;";
            OracleCommand cmd = new OracleCommand("select * from xxxx", conn);
            conn.Open();
            cmd.CommandType = CommandType.Text;

            DataSet ds = new DataSet();
            OracleDataAdapter da = new OracleDataAdapter();
            da.SelectCommand = cmd;
            da.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];

            // Close and Dispose OracleConnection object
            conn.Close();
            conn.Dispose();
            Console.WriteLine("Disconnected");

using Oracle dataadapter

using (OracleConnection conn = new OracleConnection("user id=xxxx;password=xxxx;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xxxxx)(PORT=xxxx))(CONNECT_DATA=(SERVICE_NAME=xxxxxx)))"))
            //using (OracleCommand cmd = new OracleCommand("select * from xxxx", conn))
            //{
            //    conn.Open();
            //    using (OracleDataReader reader = cmd.ExecuteReader())
            //    {
            //        DataTable dataTable = new DataTable();
            //        dataTable.Load(reader);
            //        dataGridView1.DataSource = dataTable;
            //    }
            //}
0

There are 0 answers