Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with null value
Message
 
 
À
09/06/2014 15:39:56
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01601518
Message ID:
01601525
Vues:
26
>
>insertCommand.Parameters.Add("@accessPassNo", SqlDbType.Decimal, 17).Value = (this.passTable == PassTable.Access) ? passNo : null;
>
>
>it may have to be DbNull
>
>
>>Can you show what do you mean? I can not use inline IIF but I believe with that new code it should work. I'm going to test my new code in a few minutes.

No, without (Int64?) the top line doesn't compile.

If you check the link I found

http://stackoverflow.com/questions/4555935/how-to-assign-null-to-a-sqlparameter

it explains that the problem is with inline IIF that expects both parts of expression to be the same type.

BTW, I tested my new code and it worked fine.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform