Connection must be opened for this operation ERROR

Dim cn As New Oracle.DataAccess.Client.OracleConnection("Data Source=server;User ID=test;Password=test;")

cn.Open()

Try

Dim sqlstr As String

sqlstr = "select * from ash"

Dim cmd As New Oracle.DataAccess.Client.OracleCommand(sqlstr, cn)

Dim dr As New OracleDataAdapter

dr.SelectCommand = cmd

Dim ds As New DataSet

dr.Fill(ds, "test")

DataGridView2.DataSource = ds

Catch ex As Exception

Throw ex

End Try

When i run this it always give me the connection must be open for this operation. How do i solve this. Let me know any solutions.

Thanks,
Kris



Answer this question

Connection must be opened for this operation ERROR

  • Quang N

    Hi,

    am also getting the same problem and have drilled it down to the point where you create the oracledataadapter object and attempt to fill it.(In my case I am using a datareader and immediately i do an executereader on the command object the error pops up) I read on some forums somewhere to check the location of oraops.dll, they said that the one that resides in c:\windows\system32 is an incorrect version.
    anyways i am going to check it out and see if it solves my problem.
    will fill you in on what happens.

    Regards,

    mike



  • albatroz

    Check you connection string, there might be an error in there, like wrong user Id, and/or wrong password, that is preventing you to open a connection to your database.

    Regards,

    -chris

  • Dwarf

    hi,

    the solution is as follows:

    Reinstall the Oracle Data Access components and specify in the location option :

    OraDb10g_home1 instead of
    OraClient10g_home1

    This will point Oracle to the right location to find Odp.NET provider (which is causing the error)

    Let me know if this works for you.

    Regards,

    Mike

  • Brian Clark BCBSMT

    You have to verify if the version of the ODAC is the same in the development machine and the target machine.



  • Connection must be opened for this operation ERROR