The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

fparadis (1) [Avatar] Offline
#1
I am trying to update an attrubute with a null value (nullable) . The code work at runtime, but the action is not reflected on SQL Server 2000. . I am a beginner , so i am not sure of what i am doing wrong.

Here is the code :

(Check for the attribute "IntermediaireReferenceNiveau1")


using (Linq.RetributionAuxIntermediairesDataClassesDataContext
ctx = new Linq.RetributionAuxIntermediairesDataClassesDataContext(Facade.Retribution.ConnectionStringRetribution,
Facade.Retribution.RetributionLinqMappings))
{
Linq.Compte linqCompte = new Linq.Compte();
linqCompte.Id = unCompte.Id;
linqCompte.TimeStamp = unCompte.Timestamp.StringToTimestamp();
linqCompte.SystemeIdentificationCompte = unCompte.SystemeIdentification;
ctx.Comptes.Attach(linqCompte);

linqCompte.IndicateurProtectionDonneeNominative = Convert.ToChar(unCompte.IndicateurProtectionDonneeNominative);
if (unCompte.IntermediaireReferenceNiveau1 == null)
{
linqCompte.IntermediaireReferenceNiveau1 = null;
}
else
{
linqCompte.IntermediaireReferenceNiveau1 = unCompte.IntermediaireReferenceNiveau1.Id;
}

if (unCompte.IntermediaireReferenceNiveau2 == null)
{
linqCompte.IntermediaireReferenceNiveau2 = null;
}
else
{
linqCompte.IntermediaireReferenceNiveau2 = unCompte.IntermediaireReferenceNiveau2.Id;
}

ctx.SubmitChanges();