Object state error with ASP.NET / ODP.NET

G

Guest

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
 
G

Guest

No.

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


Val Mazur said:
Hi,

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

--
Val Mazur
Microsoft MVP


dweezil said:
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
 
D

David Browne

dweezil said:
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
 
G

Guest

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 said:
No.

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


Val Mazur said:
Hi,

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

--
Val Mazur
Microsoft MVP


dweezil said:
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
 
G

Guest

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.
 
V

Val Mazur

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 said:
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 said:
No.

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


Val Mazur said:
Hi,

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

--
Val Mazur
Microsoft MVP


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
 
Top