.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 12th, 2003, 12:02 AM
whatadonk whatadonk is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: New South Wales, Australia
Posts: 1 whatadonk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Connecting to Oracle with C#

Hi everyone,

I am trying with little success to get a simple C# application to execute queries on a remote Oracle database using ODBC, OLEDB or ODP.NET. I have searched the web extensively and found hundreds of C# and VB code examples but none of them seem to work.

I have successfully installed Oracle9i (9.2.0.1.0) on Redhat8.0.
I have installed Oracle9i clients on my Windows XP Professional machine and can connect to the database using sqlplus from both Windows and Linux. I have installed MDAC2.7, ODBC .NET data provider (odbc_net.msi) and ODP.NET.

My main problem seems to be with the ODBC Data Sources configuration. I have configured the ODBC sources successfully for MySQL using MyODBC but really need to get Oracle working. It is my understanding that C# references the ODBC Sources on a machine using a Data Source Name (DSN), this DSN is configured in the ODBC Administration section of Control Panel -> Administrative Tools -> ODBC Data Sources. For Microsoft ODBC for Oracle this DNS comprises a Data Source Name, Description, User name and Server. What do I use for the Server field? I read in the help and on the web that this is an SQL*Net Easy configuration connection string or database alias. I have ran the Net Configuration Assistant and Net Manager applications installed with the oracle9i windows clients and configured the server IP and port and SID and tried setting the server field in the DNS to point to the service name configured with Net Manager. But no connections.

Am I correct in my assumption that

.NET code (C#) -> ODBC Data sources (DNSs) -> Oracle9i clients -> Oracle 9i DB

If so how does ODBC know where to look for Oracle service name configurations?
Is there a special place I should be installing Oracle clients on windows so .NET/ODBC knows where they are?
Is there an environmental variable I should be setting so .NET/ODBC Sources can find Oracle service names?

Currently there is no reference to my servers IP address or port anywhere but the Oracle9i service name / tnsnames.ora file. Should the server field in the ODBC DNS section contain this information?

I am this executing code having imported/using Microsoft.Data.Odbc;

string connString = "Driver={Microsoft ODBC for Oracle};DNS=oracle9i_cs;UID=scott;PWD=tiger";
OdbcConnection conn = new OdbcConnection(connString);
conn.Open();

where oracle9i_cs is the SystemDNS i configured in ODBC Data Sources with SystemDNS settings for a Miscorosft ODBC for Oracle connection:-

Data Source Name: oracle9i_cs
Desription: Oracle9i CSharp
User Name: scott
Server: oracle9i (service name configured in Windows Oracle Net Manager/Net Nonfig)

Is this correct or am i missing something silly?
Should I be pointing directly to my oracle database on Linux with the DNS?
The errors i am getting are of the form

Unhandled Exception: Microsoft.Data.Odbc.OdbcException: ERROR [IM006] [Microsoft]
[ODBC Driver Manager] Driver's SQLSetConnectAttr failed
ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the ve
rsion of ODBC behavior that the application requested (see SQLSetEnvAttr).
ERROR [01S00] [Microsoft][ODBC driver for Oracle]Invalid connection string attribute
at Microsoft.Data.Odbc.OdbcConnection.Open()
at OracleTest.OracleTester.test()
at OracleTest.OracleTester.Main(String[] args)

I searched these error codes on google and found a few sites with seemingly unrelated problems. Any one have any ideas?

Getting desperate

Many thanks
Trent
Comments on this post
Gran Roguismo agrees!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Connecting to Oracle with C#

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap