c# - SqlCeCommand nullable values -
my code:
sqlceconnection sql = new sqlceconnection(@"data source=c:\db.sdf"); sql.open(); cmd = new sqlcecommand("insert xxx(aaa) values(@aaa)", sql); string param = null; //doesn't work //string param = "blah" //works cmd.parameters.addwithvalue("@aaa", param); cmd.executenonquery(); //(1) sql.close();
(1) throws exception when param
null. database allows value in collumn aaa
null. how can insert null table xxx ?
exception:
parameterized query 'insert xxx(aaa) values(@aaa)' expects parameter value not supplied.
try using dbnull.value
instead:
var param = dbnull.value;
Comments
Post a Comment