Connect to ORACLE DATABASE through ODBC connection....

Hi experts !
Ok, let 's go... :

I want to connect to a ORACLE database through an ODBC connection :

I've imported "Imports System.Data.Odbc", doing this :



MyDbServerConnection.ConnectionString = Str



        Try
            MySelectCmd.Connection = MyDbServerConnection
            'MySelectCmd.CommandText = "select * from test_table"

            MyAdapter.SelectCommand = MySelectCmd

            Dim ds As New DataSet
            MyAdapter.Fill(ds, "test_table")


            DataGrid1.DataSource = ds
        Catch ex As Exception
            MessageBox.Show("Error: " & ex.Message)
        End Try



I've tried Str with this :

DSN=DiaDia;user id=[User];password=[PASS ]
Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=[User];pwd=[PASS ]
Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=[User];pwd=[PASS ]


With errors....

Maybe I' would have to use  : Imports System.Data.OleDb  ?  ? ?

 Dim oCon As New OleDbConnection
        Dim oAdapter As New OleDbDataAdapter
        Dim oCmd As New OleDbCommand
        oCon.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd;"



        Try
            oCmd.Connection = oCon
            oCmd.CommandText = "Select * from Test_Table"

            oAdapter.SelectCommand = oCmd

            Dim ds As New DataSet
            MyAdapter.Fill(ds, "test_table")


            DataGrid1.DataSource = ds
        Catch ex As Exception
            MessageBox.Show("Error: " & ex.Message)
        End Try


Thanks !!
LVL 1
franklinanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Naveen SwamyYash Infinite Solutions Private LimitedCommented:
VB.NET
Dim oOleDbConnection As OleDb.OleDbConnection
Dim sConnString As String = _
         "Provider=OraOLEDB.Oracle;" & _
         "Data Source=MyOracleDB;" & _
         "User ID=myUsername;" & _
         "Password=myPassword"
oOleDbConnection = New OleDb.OleDbConnection(sConnString)
oOleDbConnection.Open()


or,


' VB.NET
Dim oODBCConnection As Odbc.OdbcConnection
Dim sConnString As String = _
         "Driver={Microsoft ODBC for Oracle};" & _
         "Server=OracleServer.world;" & _
         "Uid=myUsername;" & _
         "Pwd=myPassword"
oODBCConnection = New Odbc.OdbcConnection(sConnString)
oODBCConnection.Open()


or,


Imports System.Data.OracleClient
 
Dim oOracleConn As OracleConnection = New OracleConnection()
oOracleConn.ConnectionString = "Data Source=Oracle8i;" & _
                               "Integrated Security=SSPI";
oOracleConn.Open()



Also there is ODP.NET from Oracle. SHould be very compatible to .NET

http://otn.oracle.com/tech/windows/odpnet/content.html

*****************************************

 ODBC


 Standard Security:
"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Uid=Admin;Pwd=;"


 Workgroup:
"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;SystemDB=C:\mydatabase.mdw;","admin", "" 


 Exclusive:
"Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\mydatabase.mdb;Exclusive=1;Uid=admin;Pwd="


 OLE DB, OleDbConnection (.NET)


 Standard security:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;User Id=admin;Password=asdasd;"


 Workgroup (system database):
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:System Database=system.mdw;","admin", "" 


 With password:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;Jet OLEDB:Database Password=MyDbPassword;","admin", "" 


 Oracle
 ODBC


 New version:
"Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;"


 Old version:
"Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;"


 OLE DB, OleDbConnection (.NET)


 Standard security:
"Provider=msdaora;Data Source=MyOracleDB;User Id=UserName;Password=asdasd;"
This one's from Microsoft, the following are from Oracle
 Standard Security:
"Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd;"


 Trusted Connection:
"Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;"


 OracleConnection (.NET)


 Standard:
"Data Source=Oracle8i;Integrated Security=yes";
This one works only with Oracle 8i release 3 or later
 Declare the OracleConnection:

C#:
using System.Data.OracleClient;
OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString = "my connectionstring";
oOracleConn.Open();

VB.NET:
Imports System.Data.OracleClient
Dim oOracleConn As OracleConnection = New OracleConnection()
oOracleConn.ConnectionString = "my connectionstring"
oOracleConn.Open()


 Data Shape


 MS Data Shape:
"Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;user id=username;password=mypw"


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.