Impossible d'effectuer un cast d'un objet de type "system.DBNull"
Bonjour,
j'ai une erreur dans mon datagrid;
impossible d'effectuer un cast d'un objet de type "system.DBNull" en type "system.string".....
je vous présente mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
//Infos Fournisseurs ou Prestataires
var listInfosCheque = tab_ChequeTableAdapter.GetDataByTousChequesPrestFourn(clVariableGlobale._codeSocieteActif, clVariableGlobale._codeEtablissementActif);
foreach(var infos in listInfosCheque)
{
if (tbNumeroCheq.Text == infos.Numero_Cheque.ToString())
{
//infos Fournisseur
if (Convert.IsDBNull(infos.Code_Fournisseur))
{
Tab_Cheque _cheq = new Tab_Cheque();
{
_cheq.Code_Fournisseur = "";
}
db.SaveChanges();
}
tbNom.Text = clMethodes.GetInfosNomFour(db, infos.Code_Fournisseur);
if (infos.NumPrestataire != 0)
{
//Infos Prestataire
string[] tableau = clMethodes.GetInfosNomPrenomPrest(db, infos.NumPrestataire);
tbNom.Text = tableau[0].ToString();
tbPrenom.Text = tableau[1].ToString();
}
}
} |
cordialement
solaar