locked
Inserts and deletions not working, edits are working RRS feed

  • Question

  • Hi

    I have created a very simple project with just one Master table. Dragged the Master entity onto a form to create a bound gridview then entered below code;

    Public Class Form1
     
      Dim Context As New SampleEntities
     
      Dim GlbStage As String = "View CVs"
     
      Dim Query As System.Linq.IQueryable(Of Sample.Master) = From a In Context.Masters Where a.Stage = GlbStage Select a
     
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MasterBindingSource.DataSource = Query.ToList()
      End Sub
     
      Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        MasterDataGridView.EndEdit()
     
        MasterBindingSource.EndEdit()
     
        Context.SaveChanges()
      End Sub
     
    End Class
    Running the project, adding or deleting a row interactively is reflected in the gridview. Saving using the save button however does not update changes in the backend db but there is no error or any message.
    Edits are reflected in the backend db on save.

    I wonder if it’s something to do with fields used in the table. The full table structure is given below.
    Any ideas what the problem is?

    Thanks

    Regards

    CREATE TABLE [dbo].[Master](
    	[ApplicantID] [int] NOT NULL,
    	[id] [uniqueidentifier] NULL,
    	[user_name] [nvarchar](255) NULL,
    	[PreferredName] [nvarchar](255) NULL,
    	[Tel] [nvarchar](255) NULL,
    	[Mobile] [nvarchar](255) NULL,
    	[Address1] [nvarchar](255) NULL,
    	[Address2] [nvarchar](255) NULL,
    	[Address3] [nvarchar](255) NULL,
    	[Town] [nvarchar](255) NULL,
    	[County] [nvarchar](255) NULL,
    	[Country] [nvarchar](255) NULL,
    	[Postcode] [nvarchar](255) NULL,
    	[Over18] [bit] NULL,
    	[DOB] [date] NULL,
    	[Gender] [nvarchar](1) NULL,
    	[JobType] [nvarchar](255) NULL,
    	[NearestTube] [nvarchar](255) NULL,
    	[EmployeeStatus] [nvarchar](255) NULL,
    	[IntroSource] [nvarchar](255) NULL,
    	[CVFileName] [nvarchar](255) NULL,
    	[CVFileExtension] [nvarchar](10) NULL,
    	[CVFileSize] [int] NULL,
    	[CVFileContent] [image] NULL,
    	[CoverLetterFileName] [nvarchar](255) NULL,
    	[CoverLetterFileExtension] [nvarchar](10) NULL,
    	[CoverLetterFileSize] [int] NULL,
    	[CoverLetterFileContent] [image] NULL,
    	[BackProblems] [bit] NULL,
    	[ArthriticCondition] [bit] NULL,
    	[ME] [bit] NULL,
    	[TB] [bit] NULL,
    	[HeartComplaint] [bit] NULL,
    	[HighBloodPressure] [bit] NULL,
    	[ImpairedVision] [bit] NULL,
    	[Hepatitis] [bit] NULL,
    	[Asthma] [bit] NULL,
    	[IntestinalComplaint] [bit] NULL,
    	[PhotosensitiveEpilepsy] [bit] NULL,
    	[Seizures] [bit] NULL,
    	[MedicalOther] [bit] NULL,
    	[Allergies] [bit] NULL,
    	[CriminalRecord] [bit] NULL,
    	[BanKName] [nvarchar](255) NULL,
    	[AccountName] [nvarchar](255) NULL,
    	[SortCode] [nvarchar](255) NULL,
    	[AccountNumber] [nvarchar](255) NULL,
    	[NoUKBankAccount] [bit] NULL,
    	[NINo] [nvarchar](255) NULL,
    	[NoNINo] [bit] NULL,
    	[TaxStatementA] [nvarchar](255) NULL,
    	[TaxStatementB] [nvarchar](255) NULL,
    	[TaxStatementC] [nvarchar](255) NULL,
    	[Neck] [nvarchar](255) NULL,
    	[Shirt] [nvarchar](255) NULL,
    	[JacketSize] [nvarchar](255) NULL,
    	[SkirtWaist] [nvarchar](255) NULL,
    	[InnerLeg] [nvarchar](255) NULL,
    	[Shoe] [nvarchar](255) NULL,
    	[HeadSize] [nvarchar](255) NULL,
    	[UKContact] [nvarchar](255) NULL,
    	[UKContactTel] [nvarchar](255) NULL,
    	[NextofKin] [nvarchar](255) NULL,
    	[NextofKinTel] [nvarchar](255) NULL,
    	[ParticularsofEngagement] [bit] NULL,
    	[ConfidentialityAgreement] [bit] NULL,
    	[StaffHandbook] [bit] NULL,
    	[HealthSafetyGuide] [bit] NULL,
    	[ApplicantEnabled] [bit] NULL,
    	[LastRead] [datetime] NULL,
    	[LastUpdated] [datetime] NULL,
    	[LastUpdatedSource] [nvarchar](255) NULL,
    	[Stage] [nvarchar](255) NULL,
     CONSTRAINT [PK_Master] PRIMARY KEY CLUSTERED 
    (
    	[ApplicantID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    
    GO
    
    ALTER TABLE [dbo].[Master] ADD CONSTRAINT [DF_Master_CVFileContent] DEFAULT (NULL) FOR [CVFileContent]
    GO
    
    ALTER TABLE [dbo].[Master] ADD CONSTRAINT [DF_Master_CoverLetterFileContent] DEFAULT (NULL) FOR [CoverLetterFileContent]
    GO
    
    ALTER TABLE [dbo].[Master] ADD CONSTRAINT [DF_Master_Stage] DEFAULT (N'View CVs') FOR [Stage]
    GO
    
    Tuesday, March 1, 2011 3:20 PM

Answers