Getting Null Value Error when Inserting record

G

Guest

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

google.groups

Jeff said:
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.
 

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