Solved

Insert Null into sql??

Posted on 2003-12-04
1
546 Views
Last Modified: 2012-05-04
Hey so I have a sql insert string we'll say:
Insert INTO FooTable (val1,val2,val3) values (@val1,@val2,@val3)

I go through and add the parameters.
Now when adding the values, that can depend on what is read by the application. The problem is if the value is null.
if it is null I want to have the database be null. But the requirement for this null changed from when I originally built the app, so I can't have it dynamically create the string. Basically I want to know if I can have the value = null?

0
Comment
Question by:jj819430
1 Comment
 
LVL 18

Accepted Solution

by:
testn earned 500 total points
ID: 9876705
Just set the parameter to DBNull.Value
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question