none
Calculated columns RRS feed

  • Question

  • Hi

    I have an application that is trying to Insert a record into a table. When I try to submit the changes I get the error message: Incorrect syntax near the keyword 'IDENTITY'

    The table is defined as:

    CREATE TABLE [dbo].[PAT_DATA](
    	[NHINO] [varchar](7) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    	[YEARS]  AS ([dbo].[fn_GetAge]([DOB],getdate())),
    	[PATIENTID] [varchar](7) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    	[ISCAREPLUS] [smallint] NOT NULL,
    	[SERPROVCODE] [varchar](32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    	[CDCount] [int] NOT NULL,
    	[DOB] [datetime] NOT NULL,
    	[DEP] [smallint] NOT NULL,
    	[SURNAME] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    	[GIVENNAME] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    	[IDENTITY] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF_PAT_DATA_IDENTITY]  DEFAULT (newid()),
     CONSTRAINT [PK_PAT_DATA] PRIMARY KEY CLUSTERED 
    (
    	[IDENTITY] ASC
    )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    the C# code:

                            'create new record in PAT_DATA Table
                            Dim pat_data As New PAT_DATA
                            pat_data.NHINO = Drow.Item("NHINO")
                            pat_data.PATIENTID = Drow.Item("PATIENTID")
                            If (Drow.Item("ISCAREPLUS").ToString <> "") Then pat_data.ISCAREPLUS = Drow.Item("ISCAREPLUS") Else pat_data.ISCAREPLUS = 0
                            If (Drow.Item("SERPROVCODE").ToString <> "") Then pat_data.SERPROVCODE = Drow.Item("SERPROVCODE") Else pat_data.SERPROVCODE = "Unknown"
                            pat_data.CDCount = 0
                            pat_data.DOB = Drow.Item("DOB")
                            If (Drow.Item("DEP").ToString <> "") Then pat_data.DEP = Drow.Item("DEP") Else pat_data.DEP = 0
                            pat_data.SURNAME = Drow.Item("SURNAME")
                            pat_data.GIVENNAME = Drow.Item("GIVENNAME")
    
                            'Store temp pat_data record
                            Try
                                CDEvodb.PAT_DATAs.InsertOnSubmit(pat_data)
                            Catch ex As Exception
                                myLogging.OutputError("<" & DateTime.Now.ToString & "> " & "Error - inserting pat_data record: " & ex.Message)
                            End Try
    
                        Try
                            CDEvodb.SubmitChanges()
                        Catch ex As Exception
                            myLogging.OutputError("<" & DateTime.Now.ToString & "> " & "Error - inserting patient LTC records: " & ex.Message)
                        End Try
    


    The error seems to have something to do with the age column as when I remove it the insert works. The Age column is a calculated column which my have something to do with why its not working but I cant seem to find the solution.

    Any help would be very much appreciated.

    Cheers,
    Kevin. 


    Friday, June 19, 2009 3:25 AM

All replies