Monday, December 16, 2013

How do I get Oracle to work with ASP.NET?

I can say that Oracle and .NET is a real pain to get working.  Here are some things that took me a while to learn:

The Oracle Drivers are un-managed

Although Oracle has an xCopy version of the drivers, there are still un-managed pieces of the driver.  What that means, is that you will need to do a full install of the drivers both on your development machine and the server. 

The Oracle Drivers are either 32bit or 64bit

Install the drivers that are appropriate for your web server, either 32 bit or 64 bit.  You will also need to have the app pool for the application set to either 32 bit or 64 bit.   If you don’t, you will receive this dreaded error:

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.

Download the Oracle Drivers
Look for the Oracle Data Access Components (ODP.NET) on this link. 
http://www.oracle.com/technology/software/index.html

Driver Reference
Add a reference to the Oracle.DataAccess
Check if the references if the Oracle.DataAccess is marked to Copy local.

Visual Studio 2010 and earlier have 32 bit Casini

When you run the web application inside Visual Studio, the default web server built into Visual Studio is called Casini.  It is 32 bit.  So although you may have a 64 bit machine and 64 bit drivers, Oracle will not run in Visual Studio unless you get the 64 bit Casini version.  Visual Studio 2012 and higher has a Casini that is 64 bit.  It is interesting to note that any MSTest or NUnit tests will be run in 64 bit mode so any integration tests will work. 

http://cassinidev.codeplex.com/

Monday, December 9, 2013

How to use Teradata with .NET

I recently worked on a fairly complex report which pulled data from three different systems.  One of the databases used Teradata.

How to use Teradata with .NET


1.  Download the .NET driver:
 http://downloads.teradata.com/download/connectivity/net-data-provider-for-teradata

2.  Add a reference to both  Teradata.Client.Provider.dll and the Teradata.Net.Security.Tdgss.dll in your Visual Studio Project

3.  Create a connection string in the web or app.config.  Here is the format:
http://www.connectionstrings.com/teradata/

  


4.  Write some code to connect.
Example:

using Teradata.Client.Provider;

public class Repository
{
    public void TestConnection()
    {
        TdConnection conn = new TdConnection
        {
            ConnectionString = ConfigurationManager.ConnectionStrings["MyDatabase"].ToString()
        };
        conn.Open();
    }
}


Questions

Q:  In order to use Teradata with .NET, do I need to do a full install of the drivers on the web server or do I just need Teradata.Client.Provider.dll and the Teradata.Net.Security.Tdgss.dll?

A:  I found this out by trial.  The Teradata driver does not reference any unmanaged pieces so it can be xcopy deployed to the bin directory on your web server.




Q:  Why am I getting the error:  [Teradata Database] [8017] The UserId, Password or Account is invalid.
A:  Put this in your web.config: 

 


Q:  When am I getting this error:  The NTLM authentication token is not supported
A:  I don't know why.  I had to switch from integrated security to a normal user name and password.