Problem with System.DBNull

P

Philip Tepedino

Hi,

I'm trying to read a few values with tmp = SqlCmd.ExecuteScalar()
If tmp = null (or in this case, System.DBNull), keep going, else, run some stuff.
I'm having a problem finding, and skipping fields that are null.
I've tried the following:

If tmp.GetType.ToString <> "System.DBNull" Then
....
End If

This works, however, it generates an exception later on in my program. (the next time I call form.show() for any form)
....
An unhandled exception of type 'System.OutOfMemoryException' occurred in system.windows.forms.dll

Additional information: Error creating window handle.
....

Is there a correct way of doing this?

Thanks,

Philip Tepedino
Siemens Westinghouse Generation Services
(e-mail address removed)
 
P

Patrice Scribe

I would use the IsDBNull function but I'm not sure it will change the
exception.

If it still fails, post perhaps rather the line where you actually have this
exception rather than assuming it comes from this test (basically you would
create something several times exhausting memory ?)

Patrice

--

"Philip Tepedino" <[email protected]> a écrit dans le message de
Hi,

I'm trying to read a few values with tmp = SqlCmd.ExecuteScalar()
If tmp = null (or in this case, System.DBNull), keep going, else, run some
stuff.
I'm having a problem finding, and skipping fields that are null.
I've tried the following:

If tmp.GetType.ToString <> "System.DBNull" Then
....
End If

This works, however, it generates an exception later on in my program. (the
next time I call form.show() for any form)
....
An unhandled exception of type 'System.OutOfMemoryException' occurred in
system.windows.forms.dll

Additional information: Error creating window handle.
....

Is there a correct way of doing this?

Thanks,

Philip Tepedino
Siemens Westinghouse Generation Services
(e-mail address removed)
 
G

Greg

Look at IsDbNull or DBNull.Value


Hi,

I'm trying to read a few values with tmp = SqlCmd.ExecuteScalar()
If tmp = null (or in this case, System.DBNull), keep going, else, run some stuff.
I'm having a problem finding, and skipping fields that are null.
I've tried the following:

If tmp.GetType.ToString <> "System.DBNull" Then
...
End If

This works, however, it generates an exception later on in my program. (the next time I call form.show() for any form)
...
An unhandled exception of type 'System.OutOfMemoryException' occurred in system.windows.forms.dll

Additional information: Error creating window handle.
...

Is there a correct way of doing this?

Thanks,

Philip Tepedino
Siemens Westinghouse Generation Services
(e-mail address removed)
 
W

William Ryan

http://www.knowdotnet.com/testsite/nullvalues.html
Look at IsDbNull or DBNull.Value


Hi,

I'm trying to read a few values with tmp = SqlCmd.ExecuteScalar()
If tmp = null (or in this case, System.DBNull), keep going, else, run some stuff.
I'm having a problem finding, and skipping fields that are null.
I've tried the following:

If tmp.GetType.ToString <> "System.DBNull" Then
...
End If

This works, however, it generates an exception later on in my program. (the next time I call form.show() for any form)
...
An unhandled exception of type 'System.OutOfMemoryException' occurred in system.windows.forms.dll

Additional information: Error creating window handle.
...

Is there a correct way of doing this?

Thanks,

Philip Tepedino
Siemens Westinghouse Generation Services
(e-mail address removed)
 

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