locked
Error: Cannot set property state of [object Object] which has only a getter RRS feed

  • Question

  • Hi

    I am building a Lightswitch application in VS 2013 that connects with a MySQL database. Amongst other tables, it has the following tables:

    n-State to 1-Country

    i.e. there is State table that has a foreign key from the Country table. The Country table itself has no foreign keys.

    I have built a Browse and Add/Edit forms for the Country table and it works

    I then created a Browse and an Add/Edit form for State. The Add State form performs like this:

    Clicking the country dropdown gives me this:

    Selecting Australia results in this:

    How do I resolve this error? I tried to work around this by manually adding a record in the database. Upon reloading the Browse page, I got this error:

    I'd appreciate any help on this.

    Regards

    Zawar

    Saturday, May 7, 2016 2:08 PM

Answers

  • Hi Zawar,

    I find the problem most related to Mysql database.

    Since after I do the same operations to create the tables in MySql database, I find the relationship in LightSwich application become 1 to Many (A 'State' must have one 'Country') as below image shows.

    And when I try add State into table, I get following error message. But the record still be added into table successful and I can see the added record on BrowserState screen. The problem is not similar with you.

    In addition, my MySql version is 5.7, which is higher than yours.

    According to above operations with Mysql, I think the most problem is related to MySql database. I suggest you submit this issue to MySql forum for a better help.

    And before they response this issue, I recommend you use SQL Server Express in Visual Studio 2013. Please install SQL Server Data Tools from Control Panel -> Programs and Features -> Visual Studio 2013 -> Change -> Modify. Then you can use it from View menu -> SQL Server Object Explorer window in Visual Studio 2013.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Zawar Qayyum Tuesday, May 10, 2016 10:54 AM
    Tuesday, May 10, 2016 2:14 AM
    Moderator

All replies

  • Hi Zawar,

    According to your description, I create a sample database as a external datasourse for my LightSwithc HTML application, which contains two tables. And I set the CountryId in State table as a foreign key to connect to the Id in Country table.

    After I add Browser and Add/Edit screen for both of the tables, every screens works fine. I'm using Visual Studio Ultimate 2013 with Update 5 on Windows 8.1.

    According to the error message, it is caused by the error type for State object. Please check the DataSource relationship through right-click one of the table and double click the relationship line. I find If I just set a foreign key in State, the relationship  between State and Country is Many to One or Zero, not Many to One.

    Since I don't have MySQL, I'm using SQL Server Express. I will build a test environment to check whether this problem caused by MySQL. After testing, I will post my test result here as soon as possible.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 9, 2016 9:53 AM
    Moderator
  • Hi Weiwei

    Thanks for looking into this problem in such detail. The relationship in my model is the same as yours, except that the second statement reads "A 'State' must have one 'Country'"

    I am currently installing Visual Studio Update 5, and it is taking a lot of time. Once it is installed, I'll try to run my application again and update you.

    Other system details:

    • Windows 8
    • Visual Studio 2013 Ultimate
    • MySQL 5.6.16

    Regards

    Zawar

    Monday, May 9, 2016 1:07 PM
  • Hi Zawar,

    I find the problem most related to Mysql database.

    Since after I do the same operations to create the tables in MySql database, I find the relationship in LightSwich application become 1 to Many (A 'State' must have one 'Country') as below image shows.

    And when I try add State into table, I get following error message. But the record still be added into table successful and I can see the added record on BrowserState screen. The problem is not similar with you.

    In addition, my MySql version is 5.7, which is higher than yours.

    According to above operations with Mysql, I think the most problem is related to MySql database. I suggest you submit this issue to MySql forum for a better help.

    And before they response this issue, I recommend you use SQL Server Express in Visual Studio 2013. Please install SQL Server Data Tools from Control Panel -> Programs and Features -> Visual Studio 2013 -> Change -> Modify. Then you can use it from View menu -> SQL Server Object Explorer window in Visual Studio 2013.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Zawar Qayyum Tuesday, May 10, 2016 10:54 AM
    Tuesday, May 10, 2016 2:14 AM
    Moderator
  • Thanks a lot Weiwei. I'll put this question up in the MySQL forum.
    Tuesday, May 10, 2016 10:54 AM