MapInfo Pro Developers User Group

Welcome to the MapInfo Pro Developers community!  We are a group dedicated to the discussion and understanding of MapBasic and .Net MapInfoPro AddIn development. Bring your questions and ideas here. This group includes several members of the Pro development team from around the world.

Please feel free to start a discussion in the discussion tab or join in a conversation.

Product Information  Ideas Portal  MapInfo Community Downloads

Discussions

Members

Resources

Events

 View Only
  • 1.  How do I show an SQL Select output on the map that resulted from a User Interface?

    Posted 02-09-2018 04:03

    '*********************************************************

    'Using a User Interface by selecting the query parameters

    '*********************************************************

    Dialog

    Title "Query Parameters"

    Control StaticText

    Title "Select Landuse"

    Control RadioGroup

    Title LandUse

    ID 1

     

    Control StaticText

    Title "Select Zoning"

    Control ListBox

    Title Zoning

    ID 2

     

    Control StaticText

    Title "Select Suburb"

    Control PopupMenu

    Title Suburb

    ID 3

     

    Control OKButton

    Control CancelButton

    Calling Query

    End Sub

    '*******************************************************************

    'Running the SQL Select using the parameters and display on the map

    '*******************************************************************

    Sub Query

    Select PrimaryLanduseType, PermissibleLandUse from PermissibleLandUse, mlnk_Suburbs

    Where PermissibleLandUse.obj Within mlnk_Suburbs.obj

    And PrimaryLanduseType = "ReadControlValue(1)"

    And PermissibleLanduse.Zoning = "ReadControlValue(2)"

    And mlnk_Suburbs.Locality = "ReadControlValue(3)"

    End Sub

     



  • 2.  RE: How do I show an SQL Select output on the map that resulted from a User Interface?

    Employee
    Posted 02-11-2018 16:57

    I would add an 'into myquery?' clause to your select statement so that you know the name of the output table (otherwise it goes into the special table 'selection').

     

    Then simply add the statement: map from myquery -- if you want to add to new map

    or  to add to an existing map something like this:  add map window frontwindow() auto layer myquery



  • 3.  RE: How do I show an SQL Select output on the map that resulted from a User Interface?

    Posted 02-12-2018 20:56

    Hi Bob, thanks for the hint.  I had included ?your suggestion into the statement and no errors when compiling the program however its still not displaying on the map.   Also 'selection' or 'myquery' were not seen when the I open table browser to view them. I do not have a problem when I hard quote the variables in the query.  Sub Query

     

    Select PrimaryLanduseType, PermissibleLandUse from PermissibleLandUse, mlnk_Suburbs

    Where PermissibleLandUse.obj Within mlnk_Suburbs.obj

    And PrimaryLanduseType = "Rural"

    And PermissibleLanduse.Zoning = "Rural"

    And mlnk_Suburbs.Locality = "Baldivis"

    End Sub

    Are there any examples of similar mapbasic programs which I could view and see what I could be missing.

     



  • 4.  RE: How do I show an SQL Select output on the map that resulted from a User Interface?

    Posted 02-12-2018 21:11

    Hi Nasi,

    The "Run Command" statement should help you out. Construct your SQL as a string:

    sSQL = "Select PrimaryLanduseType, PermissibleLandUse from PermissibleLandUse, mlnk_Suburbs Where PermissibleLandUse.obj Within mlnk_Suburbs.obj And PrimaryLanduseType = """ + sVal1 + """ And PermissibleLanduse.Zoning = """ + sVal2 + """ And mlnk_Suburbs.Locality = """ + sVal2 + """"

    Then execute the sSQL string using Run Command:

    Run Command sSQL



  • 5.  RE: How do I show an SQL Select output on the map that resulted from a User Interface?

    Posted 02-13-2018 00:44

    Hi James,  I did a copy and paste and ?no errors appeared when compiling. However the results was still being able to display on the map.  Thank you for the hints.



  • 6.  RE: How do I show an SQL Select output on the map that resulted from a User Interface?

    Posted 02-14-2018 20:24

    Hi Nasi,

    My code was just an example, rather than something you can just copy and paste!



  • 7.  RE: How do I show an SQL Select output on the map that resulted from a User Interface?

    Posted 02-14-2018 20:57

    Hi James, I am still working on the changes.  Cheers.



  • 8.  RE: How do I show an SQL Select output on the map that resulted from a User Interface?

    Employee
    Posted 02-15-2018 06:02

    Nasi,

    Also remember to include Bob's statement for actually adding the resulting query to a map:

    add map window frontwindow() auto layer myquery

    where myquery is the name of the query you just created



  • 9.  RE: How do I show an SQL Select output on the map that resulted from a User Interface?

    Posted 02-19-2018 19:13

    Hi Peter, thank you for the advise.  I will keep you guys updated on ?the project.