Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 3 of 3

At my wits end with mappoint & ImportTerritories() with VB.NET

This is a discussion on At my wits end with mappoint & ImportTerritories() with VB.NET within the Development forums, part of the MapPoint Desktop Discussion category; Hi, I'm attempting to create a program that imports a set of postal sectors into mappoint as a territory code ...

  1. #1
    a_jam_sandwich is offline Junior Member White Belt
    Join Date
    Sep 2006
    Posts
    2

    Unhappy At my wits end with mappoint & ImportTerritories() with VB.NET

    Hi,

    I'm attempting to create a program that imports a set of postal sectors into mappoint as a territory code below.

    Code:
        Private Sub ImportDataTableInvoke(ByVal DataTable As DataTable)
            mobjMapPoint.NewMap(GeoMapRegion.geoMapEurope)
            mobjMapPoint.Visible = False
            Try
                ' TempFile
                Dim stmTempFile As New IO.StreamWriter(mstrFilename, False)
                ' Headings
                stmTempFile.WriteLine("Name, PostcodeSector")
                ' Loop though the record set
                For Each rowDataRow As DataRow In DataTable.Rows
                    stmTempFile.WriteLine(CStr(rowDataRow("Territory")) & "," & CStr(rowDataRow("PostcodeSector")).ToLower)
                Next
                ' Close file
                stmTempFile.Close()
    
                Dim Fields(,) As Object = { _
                    {"Name", GeoFieldType.geoFieldTerritory}, _
                    {"PostcodeSector", GeoFieldType.geoFieldPostal3} _
                                          }
    
                Dim objDataset As MapPoint.DataSet
    
                objDataset = mobjMapPoint.ActiveMap.DataSets.ImportTerritories(mstrFilename, Fields, GeoCountry.geoCountryUnitedKingdom, GeoDelimiter.geoDelimiterComma, )
                ' Set the map style
                mobjMapPoint.ActiveMap.MapStyle = GeoMapStyle.geoMapStyleData
                ' Zoom in
                objDataset.ZoomTo()
                ' Success 
                mblnImportFailed = False
            Catch ex As Exception
                Debug.WriteLine(ex.ToString)
                mblnImportFailed = True
            End Try
        End Sub
    The above returns the error message 'The territory set was empty, so territories were not created on the map and the set was deleted.' I have no idea what that means?

    The other weird and strange thing is if I let mappoint decide whats best by importing using the code below

    Code:
    objDataset = mobjMapPoint.ActiveMap.DataSets.ImportTerritories(mstrFilename, System.Reflection.Missing.Value, GeoCountry.geoCountryUnitedKingdom, GeoDelimiter.geoDelimiterComma, )
    Mappoint will draw the map but on a few datasets it returns 'No matching method defined for these fields.' I'm taking this to be that mappoint doesn't know where that postcode sector is? if so how do I get around this error?

    Thanks

    Andy

  2. #2
    davidb is offline Senior Member Blue Belt
    Join Date
    Oct 2003
    Location
    London
    Posts
    290

    Re: At my wits end with mappoint & ImportTerritories() with VB.NET

    Hi Andy. This will probably be of no help whatsoever as I know nothing about programming in vb.net. However I have set up various territories definitions in the UK based on postal geography both manually and using vba in excel. I used to get lots of error messages and incorrect plotting of sectors until it became apparent that there is a casing problem in MPE2006 and that the only way to get around this is to read the sector names in lower case rather than upper case eg kt17 4 instead of KT17 4. Not sure if your frustrations could be wound up with this but it might be worth giving it a try.

    Rgds
    David
    UK mapping and map analysis services at www.broomanalysis.plus.com

  3. #3
    a_jam_sandwich is offline Junior Member White Belt
    Join Date
    Sep 2006
    Posts
    2

    Re: At my wits end with mappoint & ImportTerritories() with VB.NET

    Thanks for your reply and have found that problem with the uppercase before, and at the time that caused a headacke.

    I have solved my problem by;

    Creating a MapPoint file with the territory dataset linked to a file and opening that file within my application as a template. The territory file is updated within my application and eachtime the territory dataset gets updated using 'mobjMapPoint.ActiveMap.DataSets.Item(1).UpdateLin k()'. Much to my amazement not even that always works and sometimes produces a COM error stating that the dataset has failed to be updated (always the same files). But even more amazing is if I call that above function for a second time the file links correctly. I also tried this updating within mappoint and the same happens.


    My conculsion is that MapPoint is pap! It's a peice of software that just about works

    Arh well.

    Thanks

    Andy

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27