Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Object Reference Error When Inserting Parent Row in Grid using LINQtoSQL

Object Reference Error When Inserting Parent Row in Grid using LINQtoSQL

Scheduled Pinned Locked Moved LINQ
csharpcsslinqhelpworkspace
4 Posts 2 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    syed81
    wrote on last edited by
    #1

    Hi, I am using LINQtoSQL to bind Grid in Hierarchical View.I have two tables SSCDWorkFlows1 and SSCDWorkFlowTasks1. SSCDWorkFlows1 : WorfkFlowID - Primarykey WorkFlowName, Sequence, ... SSCDWorkFlowTasks1: WorkFlowTaskID - PrimaryKey WorkFlowName, Sequence, .... I have created Entity Classes for WorkFlow and WorkFlowTask. For WorkFlowName i have created relationship between them using Association Attribute as below. WorkFlow: Imports System.Data.Linq Imports System.Data.Linq.Mapping <table(name:> _ Public Class Workflow <column(isprimarykey:> _ Private WorkFlowID As Integer Private mWorkflowName As String Private mTableName As String Private mSequence As Integer Private mDisplayName As String Private mAttributes As Integer Private _WorkFlowTasks As EntitySet(Of WorkflowTask) <association(name:> _ Public Property WorkFlowTasks() As EntitySet(Of WorkflowTask) Get Return Me._WorkFlowTasks End Get Set(ByVal value As EntitySet(Of WorkflowTask)) Me._WorkFlowTasks.Assign(value) End Set End Property <column()> _ Public Property WorkFlowName() As String Get Return mWorkflowName End Get Set(ByVal value As String) mWorkflowName = value End Set End Property <column()> _ Public Property TableName() As String Get Return mTableName End Get Set(ByVal value As String) mTableName = value End Set End Property <column()> _ Public Property Sequence() As Integer Get Return mSequence End Get Set(ByVal value As Integer) mSequence = value End Set End Property <column()> _ Public Property Attributes() As Integer Get Return mAttributes End Get Set(ByVal value As Integer) mAttributes = value End Set End Property <column()> _ Public Property DisplayName() As String Get Return mDisplayName End Get Set(ByVal value As String) mDisplayName = value End Set End Property End Class WorkFlowTask: Imports System.Data.Linq Imports System.Data.Linq.Mapping <table(name:> _ Public Class WorkflowTask <column(isprimarykey:> _ Private WorkFlowTaskI

    P 1 Reply Last reply
    0
    • S syed81

      Hi, I am using LINQtoSQL to bind Grid in Hierarchical View.I have two tables SSCDWorkFlows1 and SSCDWorkFlowTasks1. SSCDWorkFlows1 : WorfkFlowID - Primarykey WorkFlowName, Sequence, ... SSCDWorkFlowTasks1: WorkFlowTaskID - PrimaryKey WorkFlowName, Sequence, .... I have created Entity Classes for WorkFlow and WorkFlowTask. For WorkFlowName i have created relationship between them using Association Attribute as below. WorkFlow: Imports System.Data.Linq Imports System.Data.Linq.Mapping <table(name:> _ Public Class Workflow <column(isprimarykey:> _ Private WorkFlowID As Integer Private mWorkflowName As String Private mTableName As String Private mSequence As Integer Private mDisplayName As String Private mAttributes As Integer Private _WorkFlowTasks As EntitySet(Of WorkflowTask) <association(name:> _ Public Property WorkFlowTasks() As EntitySet(Of WorkflowTask) Get Return Me._WorkFlowTasks End Get Set(ByVal value As EntitySet(Of WorkflowTask)) Me._WorkFlowTasks.Assign(value) End Set End Property <column()> _ Public Property WorkFlowName() As String Get Return mWorkflowName End Get Set(ByVal value As String) mWorkflowName = value End Set End Property <column()> _ Public Property TableName() As String Get Return mTableName End Get Set(ByVal value As String) mTableName = value End Set End Property <column()> _ Public Property Sequence() As Integer Get Return mSequence End Get Set(ByVal value As Integer) mSequence = value End Set End Property <column()> _ Public Property Attributes() As Integer Get Return mAttributes End Get Set(ByVal value As Integer) mAttributes = value End Set End Property <column()> _ Public Property DisplayName() As String Get Return mDisplayName End Get Set(ByVal value As String) mDisplayName = value End Set End Property End Class WorkFlowTask: Imports System.Data.Linq Imports System.Data.Linq.Mapping <table(name:> _ Public Class WorkflowTask <column(isprimarykey:> _ Private WorkFlowTaskI

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      syed81 wrote:

      "Object reference not set to an instance of an object"

      You're likely missing a New somewheres.

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      S 1 Reply Last reply
      0
      • P Paul Conrad

        syed81 wrote:

        "Object reference not set to an instance of an object"

        You're likely missing a New somewheres.

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        S Offline
        S Offline
        syed81
        wrote on last edited by
        #3

        Hi, Thanks a lot.. The problem is exactly what you mentioned, i have missed a New keyword in the declaration.I have corrected this as below. Private _WorkFlowTasks As New EntitySet(Of WorkflowTask) Now its working fine. Really it helped a lot.Thanks again. Regards Syed

        P 1 Reply Last reply
        0
        • S syed81

          Hi, Thanks a lot.. The problem is exactly what you mentioned, i have missed a New keyword in the declaration.I have corrected this as below. Private _WorkFlowTasks As New EntitySet(Of WorkflowTask) Now its working fine. Really it helped a lot.Thanks again. Regards Syed

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Usually the error message you posted, that is most likely going to be the cause. Can't tell you how many times that's happened to me :-\

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups