c# - How to insert null into an SQL string -


in c# code, have string has been concatenated build sql insert statement, , passed stored procedure , run. problem have field in concatenated string, call salary, numeric in database. however, it's being built in c# code, string. there's error in sp when comes time insert, error converting data type varchar numeric. big insert string created run in sp @ once, can't check individual values in sp. , can't make salary = string null, because inserts string "null" rather null value.

you need add logic in code this.

if string.isnullorempty(salary) {     myparameter = dbnull.value; } else {     myparameter = int.parse(salary); } 

Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -