Error : Could not load file or assembly ‘Oracle.DataAccess’ or one of its dependencies.

I ran into this problem today in a ASP.NET application on deployment:

“Exception message: Could not load file or assembly ‘Oracle.DataAccess’ or one of its dependencies. An attempt was made to load a program with an incorrect format.”

Some suggest changing your solution by going into Configuration Manager and set your target platform to 64-bit.  Others suggest enabling 32-bit applications in your AppPool.

Before doing that, make sure that your reference properties for Oracle.DataAccess have NOT been inadvertently changed to “Copy Local = true”.  Otherwise, your server will be using your copy and not the one in the GAC.

NET : Create DataTable From CSV File

DataTable dt = new
DataTable();
string line = String.Empty;
int i = 0;
using (StreamReader sr = File.OpenText(@path))
{
    while ((line = sr.ReadLine()) != null)
    {
        string[] data = line.Split(‘,’);
        if (data.Length > 0)
        {
            if (i == 0)
            {
               
int j = 0;
               
foreach (var
s in data)
                {
                   
//create column
                   
dt.Columns.Add(new DataColumn());
                   
//add column name from first row
                   
dt.Columns[j].ColumnName = data[j].ToString();
                   
j++;
               
}
               
i++;
            }
            if (i > 1)
            {
               
//if not first row (column name) then create
data row
               
DataRow row = dt.NewRow();
               
row.ItemArray = data;
              
 dt.Rows.Add(row);
            }
           
i++;
        }
    }
}
return dt;

NET : Create Dynamic SqlCommand Parameters

string IDs = “2055,1644,5889”;
List<string>
IDNumbers = IDs.Split(‘,’).ToList<string>();
StringBuilder sb = new
StringBuilder();
cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
sb.Append(“SELECT
* FROM TABLE WHERE (“
);
//build parameters
foreach (string idNumber in IDNumbers)
{
sb.Append(“TABLE.ID
= “
+ “:parm” +
idNumber.ToString());
sb.Append(” OR
);
}
sb.Remove(sb.Length – 3, 3);
sb.Append(“)
);
foreach (string idNumber in IDNumbers)
{
cmd.Parameters.Add(new
OracleParameter(“parm” +
idNumber.ToString(), idNumber));
}
cmd.ExecuteNonQuery();

SQL : Get Last Update TimeStampe For A Table

I have some Oracle tables that have no datestamp on them
that would display the last update of that row. 
Here is a query for that:
SELECT SCN_TO_TIMESTAMP( ORA_ROWSCN )
FROM YOURTABLE;
Sample output would look something like:
4/16/2014 9:01:26.000000000 AM
Of course, you can add a where clause to determine update
for your particulars.
For more information: SCN_TO_TIMESTAMP

NET : Formatting A Date For Oracle

Currently, developers must provide
date format whenever inserting date records into oracle.  Here is one approach:

public static DateTime FormatDateForOracle(string inDate)
  {
  //try to parse date into the acceptable Oracle format
  DateTime parsedDate;
  if (DateTime.TryParse(inDate,
out parsedDate))
  {
    try
        {
          return parsedDate =       DateTime.ParseExact(Convert.ToDateTime(inDate).ToString(“MM/dd/yyyy”), “MM/dd/yyyy”,
System.Globalization.CultureInfo.InvariantCulture);
        }
    catch (Exception
e)
        {
          //Handle as you see fit
        }
  }
  else
    {
       //Handle as you see fit
    }
    return
parsedDate;
}