Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • keilo 568 posts 1023 karma points
    Sep 01, 2015 @ 07:51
    keilo
    0

    Member DataType creation - SQL Error

    I was using the Member section and adding custom data types with no issues.

    For no apparent reason I am getting this error when I try to create a new data type in any (including default Member) Member Type.

    Anyone can shed some light what might be the likely issue? Would be greatly appreciated!


    The INSERT statement conflicted with the FOREIGN KEY constraint "FK_cmsPropertyType_cmsDataType_nodeId". The conflict occurred in database "STAGING", table "dbo.cmsDataType", column 'nodeId'.
    The statement has been terminated.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_cmsPropertyType_cmsDataType_nodeId". The conflict occurred in database "STAGING", table "dbo.cmsDataType", column 'nodeId'.
    The statement has been terminated.
    
    Source Error: 
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    
    Stack Trace: 
    
    [SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_cmsPropertyType_cmsDataType_nodeId". The conflict occurred in database "STAGING", table "dbo.cmsDataType", column 'nodeId'.
    The statement has been terminated.]
       System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase) +506
       System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData) +401
       System.Action`1.EndInvoke(IAsyncResult result) +0
       System.Web.UI.
  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Sep 01, 2015 @ 08:21
    Ravi Motha
    1

    Hi Keilo

    We've traced back a bit further an dit looks like one of the other datatypes is returning with a 0 instead of -92 for the Comments section

    But thats deep inside the CMS and we've not quite figured out why, in the end we had to do it programmatically and added the property via a page. Which is obviously not ideal

    We ran SQl profiler against our Umbraco User hitting the database and watch ed to see what values were attempting to be added and noticed that

    as yet, we have no solution or cause, because we have tried it with a copy of the database and that works okay, we have triend updating code etc and thats fine, it's obviously something with our environment

    regards

  • keilo 568 posts 1023 karma points
    Sep 01, 2015 @ 10:08
    keilo
    0

    Hi Ravi

    Thanks for the prompty reply.

    Can I check which table had the value reference 0 ?

    No matter what I do, if i open a memberType and click Save, I get the error message as above. Its also not one particular memberType, any of 4 have this issue.

    When I check the tables [cmsContentType] and [cmsPropertyType] for the ID of the MemberType, I dont see any particular likely column which is having reference 0.

    Did you locate this reference in a specific table? Really wanna find out whats causing it.

    Im running Express Profiler from https://expressprofiler.codeplex.com/ as its a SQLExpress 2008 R2 DB.

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Sep 01, 2015 @ 10:17
    Ravi Motha
    1

    You have to watch the profiler to see which value was wrong. for me/us it was off the top of my head the label datatype which has a ID = -92 was returning as 0 in the update table query and that was failing and therefore killing the process

    the table was cmsContentType and no we haven't isolated why , we think it may be environment related.. but have't checked that yet..

  • keilo 568 posts 1023 karma points
    Sep 01, 2015 @ 10:48
    keilo
    0

    Hey Ravi

    Thats pretty interesting because I just digged through the Express Profiler trace and I see the Label for instance Failed Password Attempts datatype shows 0 too.

    It cant be coincidence, right? I cant seem to find where (or why) its coming as 0

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Sep 01, 2015 @ 10:53
    Ravi Motha
    1

    That's the one, that's failing for me/us (Failed Password Attempts ) also and you are right that seems awfully odd.

    I've not had any more time to go back and dig through to see where that zero is being set either...whatever it is is its wrong and thats the cause but we have not identified the reason

  • keilo 568 posts 1023 karma points
    Sep 01, 2015 @ 14:33
    keilo
    0

    Guess we are onto something if Failed Password Attempts is the culprit.

    I couldnt figure out why, it was working (i.e. being able to add membertype properties with no issues) and no idea what broke it.

    If you have any finding please share here.

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Sep 01, 2015 @ 14:50
    Ravi Motha
    1

    If and when we get a chance to replicate the environment we shall see aht we can do and share that..

    Ravi

    we ended up doing a script which did this to add the property

    note psuedo code rather than actual code and you'll need to modify the ID values

    var mts = ApplicationContext.Current.Services.MemberTypeService;
    var membertype= mts.Get(5954);
    var dt = ApplicationContext.Current.Services.DataTypeService.GetDataTypeDefinitionById(-92);
    
    var pt = new PropertyType(dt) {Alias = "xxx", Name = "yyyy"};
    membertype.AddPropertyType(pt, "abc");    //property and tab name
    mts.Save(membertype);
    
  • keilo 568 posts 1023 karma points
    Sep 01, 2015 @ 14:54
    keilo
    0

    Thanks for sharing this, will give it a go when i get onto the computer.

    Can I check,after running this code manually, are you able to go to Member section and add/update existing or new properties - i.e. normalize?

    I have 4 member types, including the default and I get this error in all of them, as they share/inherit the likely culprit Failes Password Attempts.

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Sep 01, 2015 @ 15:02
    Ravi Motha
    1

    no this was just a hard and frankly dirty way to get our property onto the membertype..

  • keilo 568 posts 1023 karma points
    Sep 01, 2015 @ 15:33
    keilo
    0

    So the mystery remains...

    I have been tracing the recent activity and trying to make sense of what might cause such a thing. Cant figure out as it appeared from nowhere.

    Do you use a code where the member is created or updated programmatically in your website? Also which build of Umbraco 7 are you using?

    This is the exact SQL query throwing the error caught from the profiler;

    exec sp_executesql N'UPDATE [cmsPropertyType] SET [dataTypeId] = @0, 
    [contentTypeId] = @1, [propertyTypeGroupId] = @2, [Alias] = @3, [Name] = @4, 
    [helpText] = @5, [sortOrder] = @6, [mandatory] = @7, [validationRegExp] = @8, 
    [Description] = @9 
    WHERE [id] = @10',N'@0 int,@1 int,@2 int,@3 nvarchar(4000),@4 nvarchar(4000),
    @5 nvarchar(4000),@6 int,@7 int,@8 nvarchar(4000),@9 nvarchar(4000),@10 int',
    @0=0,@1=19003,@2=107,@3=N'umbracoMemberFailedPasswordAttempts',@4=N'Failed Password Attempts',
    @5=NULL,@6=1,@7=0,@8=N'',@9=N'',@10=336
    

    @0 parameter gets the value 0 for some weird reason.

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Sep 01, 2015 @ 15:38
    Ravi Motha
    1

    this is an existing web site and we were trying to update an existing member type, this was something we had no problem doing on our development environment, but in our production environment we have encountered this issue

    we are using 7.2.4 but have tried it with a copy of the lvie database and our local code.

    we have tried looking at it against upgraded code

    we do not plan on changing or needto change the member type again, so its a wrinkle rather than a show stopper for us at the moment

    but it doesn't explain why when we run this we can update the membertype but within umbraco it throws a wobbly

Please Sign in or register to post replies

Write your reply to:

Draft