CodeSmith Community
Your Code. Your Way. Faster!

Updating Columns with the rowguidcol property is not allowed.

Latest post 01-14-2008 2:47 PM by ransomhall. 7 replies.
  • 04-01-2007 2:52 PM

    Updating Columns with the rowguidcol property is not allowed.

    I found that the default behavior for updating a entity using SQL will try to update the RowGuid colomns, causing bugs for those of us using replication.  I found a fix in part of an email by Taylor Durden (http://community.codesmithtools.com/forums/thread/23074.aspx) that goes like this:

     Add this to the TemplateLib\CommonSqlCode.cs

    /// <summary>
            /// Check if a column is a rowguid column for replication
            /// </summary>
            /// <param name="column">DB table column to be checked</param>
            /// <returns>Identity?</returns>
            public bool IsRowGuidColumn(ColumnSchema column)
            {
                if (column.ExtendedProperties["CS_IsRowGuidCol"] != null)
                    return (bool)column.ExtendedProperties["CS_IsRowGuidCol"].Value;

                return false;
            }

    and change this block in code around line 84 in \DataAccessLayer.SqlClient\StoredProceduresXml.cst

     foreach (ColumnSchema column in cols)
      {
       if ( ! IsIdentityColumn(column) && ! IsComputed(column) && ! IsRowGuidColumn(column) )
        colsUpdatable.Add(column);
        
       if (column.NativeType.ToLower() == "timestamp")
        RowVersion = column;
      }

     And this fixed this issue for me.  I wanted to break this issue out into a seperate thread then Mr. Durden issue, but the credit belongs with him.

     Jason R. Shaver 

     

    EDIT:

     Here is a copy of the exact exception I would get before the fix:

    <Exception>

    <Description>An exception of type 'System.Data.SqlClient.SqlException' occurred and was caught.</Description>

    <DateTime>2007-04-01 11:49:49Z</DateTime>

    <ExceptionType>System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>

    <Message>Updating columns with the rowguidcol property is not allowed.

    The transaction ended in the trigger. The batch has been aborted.</Message>

    <Source>.Net SqlClient Data Provider</Source>

    <HelpLink />

    <Property name="Errors">System.Data.SqlClient.SqlErrorCollection</Property>

    <Property name="Class">16</Property>

    <Property name="LineNumber">79</Property>

    <Property name="Number">20062</Property>

    <Property name="Procedure">MSmerge_upd_7C6E2A740CDA42EFA2E905527856E63E</Property>

    <Property name="Server">data.jasonrshaver.com</Property>

    <Property name="State">1</Property>

    <Property name="ErrorCode">-2146232060</Property>

    <Property name="Data">System.Collections.ListDictionaryInternal</Property>

    <Property name="TargetSite">Void OnError(System.Data.SqlClient.SqlException, Boolean)</Property>

    <StackTrace> at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)

    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)

    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)

    at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)

    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

    at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteNonQuery(DbCommand command)

    at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DbCommand command, DbTransaction transaction)

    at MobilePro.Data.Utility.ExecuteNonQuery(TransactionManager transactionManager, DbCommand dbCommand) in C:\Users\jshaver\Desktop\Code\MobileProInvoice\MobilePro.Data (Generated)\MobilePro.Data\Utility.cs:line 385

    at MobilePro.Data.SqlClient.SqlWebsiteAccountEmployeesProviderBase.Update(TransactionManager transactionManager, WebsiteAccountEmployees entity) in C:\Users\jshaver\Desktop\Code\MobileProInvoice\MobilePro.Data (Generated)\MobilePro.Data.SqlClient\SqlWebsiteAccountEmployeesProviderBase.generated.cs:line 806

    at MobilePro.Data.Bases.EntityProviderBaseCore`2.Save(TransactionManager mgr, Entity entity) in C:\Users\jshaver\Desktop\Code\MobileProInvoice\MobilePro.Data (Generated)\MobilePro.Data\Bases\EntityProviderBaseCore.generated.cs:line 564

    at MobilePro.Services.WebsiteAccountEmployeesServiceBase.Save(WebsiteAccountEmployees entity) in C:\Users\jshaver\Desktop\Code\MobileProInvoice\MobilePro.Data (Generated)\MobilePro.Services\WebsiteAccountEmployeesServiceBase.generated.cs:line 802</StackTrace>

    <additionalInfo>

    <info name="MachineName" value="PWS670" />

    <info name="TimeStamp" value="4/1/2007 4:49:49 PM" />

    <info name="FullName" value="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />

    <info name="AppDomainName" value="7a3452bf-2-128199197582589499" />

    <info name="ThreadIdentity" value="JASONRSHAVER\jshaver" />

    <info name="WindowsIdentity" value="JASONRSHAVER\jshaver" />

    </additionalInfo>

    </Exception>

    Filed under:
    • Post Points: 5
  • 10-03-2007 1:09 PM In reply to

    Re: Updating Columns with the rowguidcol property is not allowed.

    I just wanted to add that this is still in version 2.2.  I was hoping someone checked this in, but I don't have the source control setup to do it. =(

    • Post Points: 65
  • 10-04-2007 6:42 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 922
    • Points 34,710

    Re: Updating Columns with the rowguidcol property is not allowed.

    Perhaps you could create an SVN patch for it - you don't need any special permissions or access.

    Install the Tortoise SVN client and make sure you have the latest SVN version and then make the changes. Use Tortoise to then make a patch and post it on here. We can then apply the patch.  It makes life much easier when changes are submitted as a patch.

    thanks

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 5
  • 10-05-2007 5:21 PM In reply to

    • bgjohnso
    • Top 10 Contributor
    • Joined on 09-15-2005
    • Spokane, WA
    • Posts 764
    • Points 22,530

    Re: Updating Columns with the rowguidcol property is not allowed.

    Jason,

     This has been committed in SVN 662.

    Ben Johnson
    ------------------------------
     Member of the .NetTiers team
     Visit http://www.nettiers.com
    ------------------------------

    • Post Points: 35
  • 10-15-2007 11:33 PM In reply to

    • Alex
    • Top 10 Contributor
    • Joined on 07-26-2005
    • Australia, Canberra
    • Posts 526
    • Points 10,645

    Re: Updating Columns with the rowguidcol property is not allowed.

    Hi Ben, This fix broke code for tables with uniquieidentifier as primary key and rowguid attribute at once, what do you think?
    Best regards,
    Alex.
    • Post Points: 35
  • 10-16-2007 2:26 PM In reply to

    • gnoy
    • Not Ranked
    • Joined on 10-16-2007
    • Posts 1
    • Points 65

    Re: Updating Columns with the rowguidcol property is not allowed.

    I had the same thing happen, crippling nearly all of my apps. I had to revert changes in 662 to get them working again.

    Hope this is resolved soon. I know this change is convenient for a few, but can't it be used in a patch as before?

    Thanks for all your guys' hard work.Smile

     

     

    • Post Points: 65
  • 10-19-2007 10:34 AM In reply to

    • bgjohnso
    • Top 10 Contributor
    • Joined on 09-15-2005
    • Spokane, WA
    • Posts 764
    • Points 22,530

    Re: Updating Columns with the rowguidcol property is not allowed.

    What exactly breaks?  Can you give me a schema that causes the error?  I would think that we should be able to come up with a solution that works in both cases.

    Ben Johnson
    ------------------------------
     Member of the .NetTiers team
     Visit http://www.nettiers.com
    ------------------------------

    • Post Points: 5
  • 01-14-2008 2:47 PM In reply to

    • ransomhall
    • Not Ranked
    • Joined on 03-19-2007
    • Raleigh, NC
    • Posts 1
    • Points 5

    Re: Updating Columns with the rowguidcol property is not allowed.

    We're also getting a problem with this error when a table PK ia also a rowguid for replication, as mentioned above. Would love to know if anybody has a fix...

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