Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Default SqlParameter Value To Null
Message
De
12/02/2009 00:46:47
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01381129
Message ID:
01381158
Vues:
31
>I have the following piece of code:
>
>
>SqlParameter PartDesc = new SqlParameter();
>PartDesc.SqlDbType = SqlDbType.VarChar;
>PartDesc.ParameterName = "@Part_Description";
>PartDesc.Value = txtPartDesc.Text;
>
>
>If the user didn't type anything into the txtPartDesc field, how would ensure that NULL was passed to the stored procedure?

You could also make the parameter option in your query and default it to NULL. Test the value of the txtPartDesc.Text and conditionally provide the parameter.
Very fitting: http://xkcd.com/386/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform