title: Oracle Database Connection
body: <p>I'm beginner about web programming and I have a problem with oracle db connection. My code is working well with Mssql but it's not working with oracle. I want to change db to oracle from mssql.
  I have downloaded odac. Here is my SqlOperations class.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data;
  using Oracle.DataAccess;
  using System.Data.OracleClient;
  using System.Data.Odbc;
  using System.Linq;
  using System.Web;
  
  namespace BagciEmlak
  {
  public class SqlOperations
  {
      OracleConnection con;
      OracleCommand cmd;
      OracleDataAdapter sda;
      DataTable dt;
      public OracleConnection OracleConnect()
      {
          try
          {
              con = new OracleConnection ("Data Source=SYS-CDB12c; User ID=HR; Password=hr; Unicode=true;");
              con.Open();
              return con;
          }
          catch (OracleException e)
          {
  
              throw;
          }
  
      }
      public int Command(string ConStr, OracleConnection conn)
      {
          try
          {
              cmd = new OracleCommand(ConStr, conn);
  
              return cmd.ExecuteNonQuery();
          }
          catch (Exception e)
          {
  
              throw;
          }
          finally
          {
              cmd.Dispose();
              conn.Close();
              conn.Dispose();
          }
  
  
      }
      public DataTable GetDataTable(string ConStr, OracleConnection conn)
      {
          try
          {
              dt = new DataTable();
              sda = new OracleDataAdapter(ConStr, conn);
              sda.Fill(dt);
  
              return dt;
          }
          catch (Exception e)
          {
  
              throw;
          }
          finally
          {
              sda.Dispose();
              conn.Close();
              conn.Dispose();
          }
  
      }
      public DataRow GetDataRow(string ConStr, OracleConnection conn)
      {
          dt = GetDataTable(ConStr, conn);
          if (dt.Rows.Count==0)
          {
              return null;
          }
          else
          {
              return dt.Rows[0];
          }
      }
      public string GetDataCell(string ConStr, OracleConnection conn)
      {
          dt = GetDataTable(ConStr, conn);
          if (dt.Rows.Count == 0)
          {
              return null;
          }
          else
          {
              return dt.Rows[0][0].ToString();
          }
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and here is my webconfig code:</p>
  
  <pre><code>&lt;connectionStrings&gt;
      &lt;add name="{ConnectionName}" 
      connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=HR;Password=HR;" 
      providerName="Oracle.DataAccess.Client"/&gt;
   &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>So whats wrong within can you help me </p>