Home » Infrastructure » Windows » Having trouble with ODP.Net
Having trouble with ODP.Net [message #602368] Tue, 03 December 2013 10:19 Go to next message
RM33
Messages: 5
Registered: December 2013
Location: New York City
Junior Member

I am using 10g with VB.Net 2010.

I was trying to get data from a field when I got this error message:

"Operation is not valid due to the current state of the object."

What's going on here? How do I fix this?

My code is below:

Dim oradb As String = "Data Source=XXXXX;User ID=XXXXX;password=XXXXX"
Dim conn As New OracleConnection(oradb)
Dim nNum As Integer
conn.Open()
Dim cmd As New OracleCommand
cmd.CommandText = "Select PSR_RPT_STAT from psrdba.RPT_PSR_SYNC"

cmd.CommandType = CommandType.Text
cmd.Connection = conn
Dim dr As OracleDataReader = cmd.ExecuteReader()

The next line causes the crash.

nNum = dr("PSR_RPT_STAT")
conn.Dispose()
Re: Having trouble with ODP.Net [message #602380 is a reply to message #602368] Tue, 03 December 2013 15:27 Go to previous messageGo to next message
Littlefoot
Messages: 19536
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I don't know the language you use; however, as noone replied (yet), let me try.

What is PSR_RPT_STAT column's data type? If I read it correctly, you want to put its contents into an INTEGER data type variable (nNum). Is nNum correctly declared?

Furthermore, SELECT statement you wrote returns all records from that table; do you, by any chance, have to restrict it to return only one record?
Re: Having trouble with ODP.Net [message #602584 is a reply to message #602380] Thu, 05 December 2013 15:15 Go to previous message
RM33
Messages: 5
Registered: December 2013
Location: New York City
Junior Member

Thanks for the reply.

I have not used ODP.Net for a while. After I posted it, I remembered that I need to use the .read command.

This fixed the problem.

If dr.HasRows Then
dr.Read()

Thanks!
Previous Topic: Installing Oracle 11g Standard with prior XE Installation
Next Topic: Creating "empty" files to use as ASM disks on Windows
Goto Forum:
  


Current Time: Mon Sep 01 14:18:04 CDT 2014

Total time taken to generate the page: 0.09307 seconds