Information générale
Catégorie:
The Mere Mortals .NET Framework
Titre:
SaveEntitiy() tries to insert NULLS
Versions des environnements
We have an issue with a desktop WinApp application where we are trying to insert a new record using the BO. When we click a button to save the entity using the SaveEntity() method a message is returned that we are trying to insert NULL values into the table. I've confirmed using SQL Profiler that indeed all the values are NULL.
However, right up until the SaveEntity() is executed, even through the validations, I can see the entity does contain the values. I'm unclear why the actual execution of the SQL INSERT loses the values in the Entity. I've included some basic code below where I'm trying to prove and resolve my problem. Can anyone advise on what I might be missing with the following code that would cause this problem?
Me.mdacAttorney.NewEntity()
With mdacAttorney.Entity
.fname = txFname.Text
.lname = txLname.Text
.mname = txMidInit.Text
.addr1 = txAddr1.Text
.addr2 = txAddr2.Text
.city = txCity.Text
.state = txState.Text
.zip = txZip.Text
.Isactive = CType(cmbActive.SelectedValue, Boolean)
.Isdeleted = False
.phone = txPhone.Text
.fax = txFax.Text
.contact_notes = txNotes.Text
.createdOn = DateTime.Now
.createdBy = "Graeme"
End With
mdacAttorney.SaveEntity()
The error message I am getting is "Cannot insert the value NULL into column 'addr1', table 'MedicalModule.dbo.attorney'; column does not allow nulls. INSERT fails. The statement has been terminated."
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement