B
Bradley Plett
I'm sorry about the cross-post, but this one has me completely
baffled. I don't know if the problem is with Oracle, .NET, Visual
Studio, my machine....
I have some very simple code (see below) in which I use a method
called ExecuteScalar. It works like a charm when run in debug mode in
VS. However, the compiled executable fails on that method.
The code snippet is as follows (sorry about the line-wrap):
--------------------------------------------------
Dim mobjOracleConnection As New
OracleConnection(mstrConnectionString)
Dim lobjCmd As New OracleCommand("SELECT MAX(TRANS_DT) AS LAST_DATE
FROM METERED_VOLUMES", mobjOracleConnection)
mobjOracleConnection.Open()
lobjCmd.ExecuteScalar
--------------------------------------------------
With various debugging statements, I have confirmed that it is
definitely the "lobjCmd.ExecuteScalar" statement that fails. If I use
any other method to get the result (e.g. "ExecuteReader") it works.
When run in the debugger, "ExecuteScalar" works like a charm. When
the compiled executable is run, it produces the following exception:
--------------------------------------------------
Exception: System.InvalidOperationException: Operation is not valid
due to the current state of the object.
at Oracle.DataAccess.Client.OracleDataReader.Read()
at Oracle.DataAccess.Client.OracleCommand.ExecuteScalar()
at ....
--------------------------------------------------
Another odd thing is that if I move the connection "Open" before the
"New OracleCommand", it still runs fine in debug but produces a
different exception when the executable runs:
--------------------------------------------------
Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at Oracle.DataAccess.Client.OracleCommand.ExecuteScalar()
at ....
--------------------------------------------------
Why the difference between debug and runtime?
Another piece of the puzzle is that the same compiled executable seems
to work fine on another machine!?! I've done as much version checking
as I can think of, and the machines seem to be configured identically.
Any thoughts?
Thanks!
Brad.
baffled. I don't know if the problem is with Oracle, .NET, Visual
Studio, my machine....
I have some very simple code (see below) in which I use a method
called ExecuteScalar. It works like a charm when run in debug mode in
VS. However, the compiled executable fails on that method.
The code snippet is as follows (sorry about the line-wrap):
--------------------------------------------------
Dim mobjOracleConnection As New
OracleConnection(mstrConnectionString)
Dim lobjCmd As New OracleCommand("SELECT MAX(TRANS_DT) AS LAST_DATE
FROM METERED_VOLUMES", mobjOracleConnection)
mobjOracleConnection.Open()
lobjCmd.ExecuteScalar
--------------------------------------------------
With various debugging statements, I have confirmed that it is
definitely the "lobjCmd.ExecuteScalar" statement that fails. If I use
any other method to get the result (e.g. "ExecuteReader") it works.
When run in the debugger, "ExecuteScalar" works like a charm. When
the compiled executable is run, it produces the following exception:
--------------------------------------------------
Exception: System.InvalidOperationException: Operation is not valid
due to the current state of the object.
at Oracle.DataAccess.Client.OracleDataReader.Read()
at Oracle.DataAccess.Client.OracleCommand.ExecuteScalar()
at ....
--------------------------------------------------
Another odd thing is that if I move the connection "Open" before the
"New OracleCommand", it still runs fine in debug but produces a
different exception when the executable runs:
--------------------------------------------------
Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at Oracle.DataAccess.Client.OracleCommand.ExecuteScalar()
at ....
--------------------------------------------------
Why the difference between debug and runtime?
Another piece of the puzzle is that the same compiled executable seems
to work fine on another machine!?! I've done as much version checking
as I can think of, and the machines seem to be configured identically.
Any thoughts?
Thanks!
Brad.