Friday, January 9, 2009

Connecting to an Oracle Database from ASP.Net/SharePoint

So you’re writing your “Hello Oracle Database” from ASP.Net/SharePoint, and you get this error: “System.Data.OracleClient Requires Oracle Client version 8.1.7 or greater”.

Perhaps you don’t really want to install the 475 Mb Oracle Client on your system just to talk to a database. Some quick googling suggests you can just install the Oracle Instant Client, and if you don’t care about internationalization, you can even go with the Instant Client “Basic Lite” which gets you down to about 18 Mb:

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/winsoft.html [32 bit version]

Yeah, it’s an order of magnitude larger than the jdbc jar you’d use if you were connecting from Java, but at least it’s not a half Gig. But what if you don’t even want to install it? This blog entry shows the 4 files you’ll need to from the instant client:

http://www.thewayofcoding.com/2008/02/c-net-programming-tip-connecting-to-an-oracle-database/

In my case, I’m actually developing a SharePoint web part. Therefore, I’d like to make the set of driver files universally available for anything deployed on the system. So I drop those four files:
· oci.dll
· orannzsbb10.dll
· oraocci10.dll
· oraociicus10.dll

into the system driver directory (in this case C:\Windows\System32). And now I’m good to go.
Note: I’m not sure if it’s related, but I did not have to change any permissions as seems to happen when you actually install the client (at least in some cases)—as described here:

http://moustafa-arafa.blogspot.com/2007/04/systemdataoracleclient-requires-oracle.html

I suppose it’s time I update my About Me to say I do .Net now too :-)

1 comment:

Scott said...

Just noticed someone came from your site to mine ( thewayofcoding.com ). I haven't done much with the these days, but I was thinking of improving it. Thanks for linking my site.