CodeSmith Community
Your Code. Your Way. Faster!

Is there something about constrants I should know ?

Latest post 06-06-2007 5:40 AM by southof40. 0 replies.
  • 06-06-2007 5:40 AM

    • southof40
    • Not Ranked
    • Joined on 06-06-2007
    • Posts 3
    • Points 45

    Is there something about constrants I should know ?

    I'm using NetTeirs 2.01 with CodeSmith 4.0 Pro Trial and I've found something weird about columns with constraints (or I think I have Smile)

    Consider the following two tables.

     USE [drs1_for_crs]
    GO
    /****** Object:  Table [ContractsRegister].[CRS_CONTRACT_INFO3]    Script Date: 06/06/2007 22:13:21 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [ContractsRegister].[CRS_CONTRACT_INFO3](
        [CNI3_AUTOID] [numeric](9, 0) IDENTITY(1,1) NOT NULL,
        [CNI3_COMMENTS] [varchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [CNSTRNT_CNI3_1]  DEFAULT (''),
     CONSTRAINT [CNI3_PK] PRIMARY KEY CLUSTERED
    (
        [CNI3_AUTOID] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    CREATE TABLE [ContractsRegister].[CRS_CONTRACT_INFO4](
        [CNI4_AUTOID] [numeric](9, 0) IDENTITY(1,1) NOT NULL,
        [CNI4_COMMENTS] [varchar](512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
     CONSTRAINT [CNI4_PK] PRIMARY KEY CLUSTERED
    (
        [CNI4_AUTOID] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]

    GO
    SET ANSI_PADDING OFF
    GO

     ... when I try to generate components based upon CRS_CONTRACT_INFO3 I get the following error message ...

     

    System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.
       at System.Data.SqlClient.SqlBuffer.get_String()
       at System.Data.SqlClient.SqlDataReader.GetString(Int32 i)
       at SchemaExplorer.SqlSchemaProvider.GetExtendedProperties(String connectionString, SchemaObjectBase schemaObject)
       at SchemaExplorer.SchemaObjectBase.get_ExtendedProperties()
       at SchemaExplorer.SchemaObjectBase.get_Description()
       at MoM.Templates.CommonSqlCode.GetColumnXmlComment(ColumnSchema column, Int32 indentLevel)
       at _CodeSmith.NetTiers_cst.IEntity.__RenderMethod1(TextWriter writer, Control control)
       at CodeSmith.Engine.DelegateControl.Render(TextWriter writer)
       at CodeSmith.Engine.Control.RenderChildren(TextWriter writer)
       at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer)
       at CodeSmith.Engine.CodeTemplate.RenderToFile(String path, Boolean overwrite)
       at _CodeSmith.NetTiers_cst.RenderToFile(String templateName, String path, Boolean overwrite)
       at _CodeSmith.NetTiers_cst.Go()
       at _CodeSmith.NetTiers_cst.__RenderMethod1(TextWriter writer, Control control)
       at CodeSmith.Engine.DelegateControl.Render(TextWriter writer)
       at CodeSmith.Engine.Control.RenderChildren(TextWriter writer)
       at CodeSmith.Engine.CodeTemplate.Render(TextWriter writer)
       at CodeSmith.Engine.CodeTemplate.RenderToString()
       at CodeSmith.Gui.CodeTemplateGenerator.f(Object A_0, EventArgs A_1)

     

     ... when I try to generate components based upon CRS_CONTRACT_INFO4 everything appears to be fine (haven't actually used the resulting classes yet but there are no errors reported).

     

    As far as I can see the only difference between the two is the default constraint on CNIx_COMMENTS - can anyone explain why this is a problem or what I should be doing differently ?

     

    Thanks in advance.

     

    Richard.


     

     

     

    • Post Points: 5
Page 1 of 1 (1 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems