Object Reference Error When Inserting Parent Row in Grid using LINQtoSQL
-
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
-
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
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
-
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
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
-
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
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