ryapos
asked on
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.AddWi thValue("@ necklacePr ice", DBNull.Value)
Else
cmdSelect.Parameters.AddWi thValue("@ necklacePr ice", Val(txtNPrice.Text))
End If
This is an ASP.NEt application written in vb.net.
Thanks
If txtNPrice.Text = "" Then
cmdSelect.Parameters.AddWi
Else
cmdSelect.Parameters.AddWi
End If
This is an ASP.NEt application written in vb.net.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can you run the sql profiler and then your application to catch what exactly is coming to sql server from your application
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.
have you tried passing Nullif(0.00,0.00) when you want a null?
https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/