troubleshooting Question

myCommand.Parameters.Add with a NULL value in a smalldatetime field

Avatar of donaldcroswell
donaldcroswell asked on
Databases.NET ProgrammingASP.NET
3 Comments1 Solution1061 ViewsLast Modified:
Hello Experts,

I'm having dramas inserting null a null value into my database smalldatetime field.

I check the fields first on the form
        Dim strDate As String
        If Trim(myDay) = "" Or Trim(myMonth) = "" Or Trim(myYear) = "" Then
            strDate = System.DBNull.Value.ToString
myCommand.Parameters.Add("@FamDOB", Data.SqlDbType.SmallDateTime).Value

For some reason if there is a value my code works, but the System.DBNull.Value.ToString doesn't work with or without quotes added.

Any help?

Fareed Ali Khan

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros