468,248 Members | 1,529 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,248 developers. It's quick & easy.

Getting Null Value Error when Inserting record

Hello all,

I have an SQL Insert statement I'm trying to run via ExecuteNonQuery. It
works fine so long as there are no nulls values. Here is the
statement...(its a shortened version of what i actually have)

MySQL = "Insert into Activity (ActivityName) Values ('" + GetString(2) + "')";
Here is the JIT Error..."Data is Null. This method or property cannot be
called on Null Values"

I'm assuming I have to use the ISDBNull method, but don't understand how to
use it when the field contains a null value. Or should I say, how do I make
it so that the INSERT statement completes and stores the null value?

Now, I do want to be able to insert null values and that is where I am
confused. I don't understand how the ISDBNULL will allow me to do that. I
double checked and in SQL Server the field is set to allow nulls. So I'
don't know what to try next.

Any help would be appreciated.

--
TIA,
Jeff Reed
Nov 17 '05 #1
1 1403

Jeff wrote:
I have an SQL Insert statement I'm trying to run via ExecuteNonQuery. It
works fine so long as there are no nulls values. Here is the
statement...(its a shortened version of what i actually have)

MySQL = "Insert into Activity (ActivityName) Values ('" + GetString(2) + "')";
Here is the JIT Error..."Data is Null. This method or property cannot be
called on Null Values"

I'm assuming I have to use the ISDBNull method, but don't understand how to
use it when the field contains a null value. Or should I say, how do I make
it so that the INSERT statement completes and stores the null value?

Now, I do want to be able to insert null values and that is where I am
confused. I don't understand how the ISDBNULL will allow me to do that. I
double checked and in SQL Server the field is set to allow nulls. So I'
don't know what to try next.


Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.