Copying over null values in DB

  • Thread starter Thread starter mavrick_101
  • Start date Start date
M

mavrick_101

Hi,

I'm saving data entered by a user. If the user does not enter a value in the
field I would like to insert null value. I want to do this so that I don't
have to write a seperate query for each column and various columns may be
left blank by the user. Instead of entering a blank space I want to enter
null (the columns in the db are nullable).

How can I do that?

Thanks.
 
How can I do that?

Firstly, you'll need to provide more information. Specifically:

1) which database are you using?
2) how are you connecting to it?
 
mavrick_101 said:
Hi,

I'm saving data entered by a user. If the user does not enter a value in the
field I would like to insert null value. I want to do this so that I don't
have to write a seperate query for each column and various columns may be
left blank by the user. Instead of entering a blank space I want to enter
null (the columns in the db are nullable).

How can I do that?

Thanks.

insert into T (id, name, comment) VALUES (5085, 'John Jones', null)
 
mavrick_101 said:
I'm saving data entered by a user. If the user does not enter a value
in the field I would like to insert null value. I want to do this so
that I don't have to write a seperate query for each column and
various columns may be left blank by the user. Instead of entering a
blank space I want to enter null (the columns in the db are nullable).

How can I do that?

You can pass DbNull.Value as the value of a parameter to get a null in the
database.
 
Back
Top