Development envionment vs runtime??

S

Stu

with the following code snippet

Dim ConOra As OracleConnection = New OracleConnection()
ConOra.ConnectionString = "User Id=USER;Password=PASSWORD;Data
Source=orcl9i;"
Dim Sql As String = "select * from CCO_MOTD order by ID "
Dim cmd As OracleCommand = New OracleCommand(Sql)
cmd.Connection = ConOra
cmd.CommandType = CommandType.Text
' Execute command, create OracleDataReader object
Dim reader As OracleDataReader = cmd.ExecuteReader()
While (reader.Read())
Message(reader.GetDecimal(12)) = reader.GetString(0)
MaxMessage = reader.GetDecimal(12)
Console.WriteLine("MSG: " + Message(MaxMessage))
End While
cmd.Dispose()

Everyone runs happy and fine in the development envionment. When I create
the install files, or run the .exe, it throws a 'Object reference not set to
an instance of an object' error at the While(reader.Read()). This happens
on other systems as well as my own.

An interesting note, when running the exe file on a coworkers machine, who's
setup is the same as mine (same version of .NET runtime, same version of
VS.NET and same version of Oracle) - things run just fine when running the
..exe file.

Where do I go from here, is this a known issue, help ?

Thanks much in advance...

Stu
 
C

Cor Ligthert

Hi Stu,

For Oracle related questions (where it can not be in the laguage because it
works on only a few machines not) is in my opininion this the best place in
the dotnet newsgroups.

Adonet
<
Web interface:

<http://communities2.microsoft.com/communities/newsgroups/en-us/?dg=microsof
t.public.dotnet.framework.adonet>

In that newsgroup will probably help Miha, one of the Bills or others you
with your question.

When you are in doubt what is the best newsgroup, crosspost it (not
multipost), crossposting is sending to more dotnet newsgroups in one time.

I hope this helps?

Cor
 
H

Herfried K. Wagner [MVP]

* "Stu said:
Dim reader As OracleDataReader = cmd.ExecuteReader()

Did you check if 'reader' is 'Nothing' there? What's the complete
exception text?
 
S

Stu

I put the following lines in to check if the reader is nothing...
if reader is Nothing then
msgbox ("reader is nothing")
else
msgbox ("reader is something")
end if

Returns that "reader is something" in both the IDE and the runtime, is the
code above the correct way to check? The complete exception text follows:

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an
object.
at MOTD.Module1.ReadFromOra() in C:\Documents and Settings\wellss\My
Documents\Visual Studio Projects\WindowsApplication2\Module1.vb:line 33
at MOTD.FrmMOTD.FrmMOTD_Load(Object sender, EventArgs e) in C:\Documents
and Settings\wellss\My Documents\Visual Studio
Projects\WindowsApplication2\FORMMOTD.vb:line 143
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

At this point I'm wondering if I'm using a different version of the ODP.NET
in the IDE than I am in the RunTime, is this possible and would this be
casuing the difference in the errors?

Thanks again!

Stu
 
H

Herfried K. Wagner [MVP]

* "Stu said:
I put the following lines in to check if the reader is nothing...
if reader is Nothing then
msgbox ("reader is nothing")
else
msgbox ("reader is something")
end if

Returns that "reader is something" in both the IDE and the runtime, is the
code above the correct way to check? The complete exception text follows:

Yes, that's correct and it tells us that this is not the reason for the
exception.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an
object.
at MOTD.Module1.ReadFromOra() in C:\Documents and Settings\wellss\My

Did you post the code of 'ReadFromOra'?
 
S

Stu

Yes, the code that was posted was from 'ReadFromOra', and using the JIT
debugger, I confimed that the exception is being thrown on

While(reader.read())

reinstalling the Oracle 9i Client and the Oracle Data Provider packages made
no difference.

Where next?
 
G

Greg Burns

Stu,

I don't know Oracle, but where do you open your connection? Where are you
closing your datareader? Probably not relevant since you say it runs in IDE
anyways.

Greg

Dim ConOra As New OracleConnection("User
Id=USER;Password=PASSWORD;Data Source=orcl9i;")
Dim Sql As String = "select * from CCO_MOTD order by ID "
Dim cmd As New OracleCommand(Sql, ConOra)

Dim reader As OracleDataReader
Try
ConOra.Open()
' Execute command, create OracleDataReader object
reader = cmd.ExecuteReader()
While (reader.Read())
Message(reader.GetDecimal(12)) = reader.GetString(0)
MaxMessage = reader.GetDecimal(12)
Console.WriteLine("MSG: " + Message(MaxMessage))
End While

Catch ex As Exception
MsgBox(ex.ToString)

Finally
If Not reader Is Nothing AndAlso Not reader.IsClosed Then
reader.Close()

If Not ConOra Is Nothing AndAlso Not ConOra.State =
ConnectionState.Closed Then ConOra.Close()

cmd.Dispose()
End Try
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top