Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Object state error with ASP.NET / ODP.NET

10 views
Skip to first unread message

dweezil

unread,
Oct 2, 2004, 8:25:04 AM10/2/04
to
Sorry for the cross-post, but I'm thinking this is either an ADO issue or a
security issue.

System.InvalidOperationException: Operation is not valid due to the current
state of the object.

I'm getting this error when I'm trying to read() from the OracleDataReader.

The reader and connection are both open, so I don't understand why I'm
getting this error.

Using: Windows 2003 Server, ODP .NET 9.2.4.0, .NET Frameworks 1.1

string groupid = "";
string fullname = "";
string ConnectString = ConfigurationSettings.AppSettings["ConnectString"];
OracleConnection dbconn = new OracleConnection(ConnectString);
OracleCommand cmd = new OracleCommand("userdetails_pkg.userdetails",dbconn);
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter param = new
OracleParameter("c_UserDetails",OracleDbType.RefCursor);
cmd.Connection = dbconn;
cmd.Parameters.Add(new
OracleParameter("p_UserName",OracleDbType.Varchar2)).Value = usr;
cmd.Parameters.Add(param).Direction = ParameterDirection.Output;
try
{
dbconn.Open();
cmd.ExecuteNonQuery();
OracleRefCursor cur = (OracleRefCursor) param.Value;
OracleDataReader odr = cmd.ExecuteReader();
while ( odr.Read() );
{
// NEXT LINE IS WHERE IT ERRORS OUT!!!
groupid = odr["groupid"].ToString();
fullname = odr["fullname"].ToString();
}
odr.Close();
odr.Dispose();
}
catch (OracleException oe )
{
lblResponse.Text = "Error: " + oe.Message;
}
finally
{
cmd.Dispose();
dbconn.Dispose();
}

--dweezil

Val Mazur

unread,
Oct 2, 2004, 2:42:30 PM10/2/04
to
Hi,

Are you using ADSI or System.DirectoryServies in your application?

--
Val Mazur
Microsoft MVP


"dweezil" <dwe...@discussions.microsoft.com> wrote in message
news:20E18A4B-4648-45D5...@microsoft.com...

dweezil

unread,
Oct 3, 2004, 5:07:04 PM10/3/04
to
No.

This is a brand new application on a new server, and I'm not using Active
Directory, I am using Forms Authenication though.

no potted meat@hotmail.com David Browne

unread,
Oct 3, 2004, 6:15:06 PM10/3/04
to

"dweezil" <dwe...@discussions.microsoft.com> wrote in message
news:20E18A4B-4648-45D5...@microsoft.com...
> Sorry for the cross-post, but I'm thinking this is either an ADO issue or
> a
> security issue.
>
> System.InvalidOperationException: Operation is not valid due to the
> current
> state of the object.
>
> I'm getting this error when I'm trying to read() from the
> OracleDataReader.
>

I belive that this is caused by not opening the ref cursor in the procedure.

create procedure foo(out_rc sysrefcursor)
is
begin
open out_rc for
select * from dual;
end;

Is there some path in your procedure where the ref cursor is not opened?

David


dweezil

unread,
Oct 4, 2004, 6:37:02 AM10/4/04
to
The RefCusor is opened...if it was not I would be receiving a different error
messge. Besides I tested this code in a C# console application and it works
fine. It seems to be a ASP.NET issue.

dweezil

unread,
Oct 4, 2004, 7:31:03 AM10/4/04
to
The RefCursor is opened. If it was not I would be receiving a different error
message. Also, this code works fine in a C# console app....it seems to be a
ASP.NET issue.

Val Mazur

unread,
Oct 5, 2004, 10:45:57 PM10/5/04
to
Hi,

I believe it could be security issue from the provider, but I cannot try it
here, because I do not have an Oracle

--
Val Mazur
Microsoft MVP


"dweezil" <dwe...@discussions.microsoft.com> wrote in message

news:DA312E8E-A999-475E...@microsoft.com...

0 new messages