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