Connecting Oracle RDB Database from VB.net

Hi All,

I am trying to connect My Oracle RDB database from my Vb.Net. I have installed ODBC driver for Oracle RDB. Now from Application I don't have any problem with connection but when I am fetching data with select statement, I am receiving this error
"ERROR [HY000] [Oracle][ODBC][Rdb]%RDB-F-BAD_DB_HANDLE, invalid database handle"
Any body has solution for this

Thanks

Tarun

My code is as follows  

    Public OdbcCmd As New OdbcCommand
    Public OdbcCon As OdbcConnection = New OdbcConnection
    Public odbcReader As OdbcDataReader
    Public ODBCConnStr As String = "DSN=ADRData;SERVER=172.25.10.21@generic@0@W;SERVER=172.25.10.21;UID=xxxx;PWD=xxxx;TLO=0;SVR=172.25.10.21;CLS=generic;XPT=2=tcp/ip;CSO=1;"

        Try
                OdbcCon = New OdbcConnection(ODBCConnStr)
                OdbcCon.Open()

         Dim odbcCMD As OdbcCommand = New OdbcCommand(strsql, OdbcCon)
         Dim dataAdapter As OdbcDataAdapter = New OdbcDataAdapter
         Dim dsTable As New DataSet
            dataAdapter.SelectCommand = odbcCMD
            dataAdapter.Fill(dsTable, "dsTable")


        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
tarun_ghoshAsked:
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.

RonaldBiemansCommented:
Why don't you use the standard oracleclient that comes with .net instea
0
RonaldBiemansCommented:
Oeps,

Why don't you use the standard oracleclient that comes with .net instead of the generic odbc adapter


like

Public Sub InsertRow(myConnection As String)
    If myConnection = "" Then
        myConnection = "Data Source=Oracle8i;Integrated Security=yes"
    End If
    Dim myConn As New OracleConnection(myConnection)
    Dim myInsertQuery As String = "INSERT INTO Dept (DeptNo, Dname, Loc) values (50, 'TECHNOLOGY', 'DENVER')"
    Dim myOracleCommand As New OracleCommand(myInsertQuery)
    myOracleCommand.Connection = myConn
    myConn.Open()
    myOracleCommand.ExecuteNonQuery()
    myConn.Close()
End Sub
0
tarun_ghoshAuthor Commented:
Hi,

This works fine with Orcle 8i or later. But I am using ORACLE RDB.

Thanks
0
tarun_ghoshAuthor Commented:
Hi

I have solved the problem.
When we create the ODBC connection there is an option  to add attached statement, we need to put the full path of the database there.
Ex:
Attach Statement: "attach 'filename vmswrk$dka100:[wiz_adr.data.rdb]wizard_data.rdb' (attach 'filename disk:[dir]db_file_name')"

Thanks

 
0
Tarun_GhoshCommented:
Attach statement is must when you are using Oracle RDB in VMS mechine.
Add the physical file name with pathe in the attach statement
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.