Insert NULL into a Money field in SQL Server

I have a form for users to enter information. If they do not enter anything into txtPrice I want it to insert NULL into the column. The column is a money column. Everytime I try this is the error I get. Implicit conversion from data type nvarchar to money is not allowed. Use the CONVERT function to run this query. Here is the code I am using to insert the data entered into the text box.

If txtNPrice.Text = "" Then
                    cmdSelect.Parameters.AddWithValue("@necklacePrice", DBNull.Value)
                Else
                    cmdSelect.Parameters.AddWithValue("@necklacePrice", Val(txtNPrice.Text))
                End If

This is an ASP.NEt application written in vb.net.

Thanks
ryaposAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anthony PerkinsCommented:
Change this:
cmdSelect.Parameters.AddWithValue("@necklacePrice", DBNull.Value)

To this:
cmdSelect.Parameters.AddWithValue("@necklacePrice", Nothing)

Or just simply:
cmdSelect.Parameters.Add("@necklacePrice", SqlDbType.Money)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Anthony PerkinsCommented:
But you may find experts more responsive in a more appropriate Topic Area such as:
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/
Aneesh RetnakaranDatabase AdministratorCommented:
can you run the sql profiler and then your application to catch what exactly is coming to sql server from your application
Anthony PerkinsCommented:
I will go out on a limb and suggest that it is never going to get beyond ADO.NET when using DBNull.Value. In other words, it will not even get close to SQL Server, let alone SQL Profiler.
LowfatspreadCommented:
have you tried passing Nullif(0.00,0.00)  when you want a null?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.