locked
.HasValue not available RRS feed

  • Question

  • So I am learning Lightswitch and some beginner VB.NET from Beth Massi's videos. I am on video 9 that reviews creating a screen to both edit and add new customer records, in one screen. Just like Beth, I add a new property that's not required and check off the box to make it a parameter and make it an integer value. I add another Item that is a query from the Customer Table (queryorDefault). I a bind the Query Parameter with the screen parameter. I then go write code to pass the parameter into the screen. I start to write this code in the initializeDataWorkSpace sections. I type Me.CustomerID.    but intelisense does not offer the .HasVAlue as an option. Any Ideas.

    FYI:

    I made sure that the Query Parameter and Screen Parameter were both Int.

    One last thing, I just checked with my Customer Table and the CustomerID is set to required. This is because my data is stored in SQL and the CustomerID is an auto generated field which makes it required. It is passed to Lightswitch that way. the fact that the CustomerID from Query is a required field shouldn't affect the .HasValue on option on the screen Parameter, should it?


    Wednesday, December 3, 2014 9:03 PM

Answers

  • OK I figured it out. Although I changed the datatype on the sql table to be int, lightswitch still read it as decimal. no matter how many times i updated the source. I wound up removing all tables and bringing them all back
    • Marked as answer by Flyersfan9474 Thursday, December 4, 2014 2:00 PM
    Thursday, December 4, 2014 2:00 PM

All replies

  • Flyersfan,

    Your CustomerID is probably string and hers is integer.  Integer has the method 'HasValue' and string does not.  Try this:

               

    If Not CustomerID Is Nothing Then

     

    End If

    HTH,

    Josh



    • Edited by joshbooker Wednesday, December 3, 2014 9:44 PM
    Wednesday, December 3, 2014 9:42 PM
  • That didn't work either. I am attaching 2 Screen Caps. The first shows the Local Property called ContactParam being not required and an integer value, the second shows my code as I write ME.ContactParam.h, HasValue is not an option. In my original post I used Customers as to not confuse and that was Beth's example, however in my DB I use contact. OK screen caps are reversed



    Thursday, December 4, 2014 1:40 PM
  • OK I figured it out. Although I changed the datatype on the sql table to be int, lightswitch still read it as decimal. no matter how many times i updated the source. I wound up removing all tables and bringing them all back
    • Marked as answer by Flyersfan9474 Thursday, December 4, 2014 2:00 PM
    Thursday, December 4, 2014 2:00 PM