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 2 of 2

Linking to data using a UDL file (MapPoint 2006)

This is a discussion on Linking to data using a UDL file (MapPoint 2006) within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, I'm wondering if anyone can help me? I have a simple form in VB that contains one button and ...

  1. #1
    sdf8pltyb is offline Junior Member White Belt
    Join Date
    Feb 2007
    Posts
    1

    Unhappy Linking to data using a UDL file (MapPoint 2006)

    Hi,
    I'm wondering if anyone can help me?
    I have a simple form in VB that contains one button and one MapPoint control. I'm only experimenting at this stage but would like the button to show/refresh data which is held on a SQL server using a UDL file.

    The form loads but error's when I click on the button.
    Here's all of the code currently attached to the form:


    Public Class MainForm


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    AxMappointControl1.OpenMap("MyBlankMap.ptm")

    'Display the toolbars

    AxMappointControl1.Toolbars.Item("location and scale").Visible = True

    AxMappointControl1.Toolbars.Item("navigation").Vis ible = True

    AxMappointControl1.Toolbars.Item("standard").Visib le = True
    End Sub



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim objApp As MapPoint.Application
    Dim objDS As MapPoint.DataSet
    Dim objMap As MapPoint.Map
    objApp.Visible = True ' The debugger stops on this line
    objApp.UserControl = True
    Dim arrFields(0 To 11, 0 To 1)
    arrFields(0, 0) = "jobid" : arrFields(0, 1) = MapPoint.GeoFieldType.geoFieldData
    arrFields(1, 0) = "jobtype" : arrFields(1, 1) = MapPoint.GeoFieldType.geoFieldData
    arrFields(2, 0) = "assignedto" : arrFields(2, 1) = MapPoint.GeoFieldType.geoFieldData
    arrFields(3, 0) = "actiondate" : arrFields(3, 1) = MapPoint.GeoFieldType.geoFieldData
    arrFields(4, 0) = "externaluser" : arrFields(4, 1) = MapPoint.GeoFieldType.geoFieldData
    arrFields(5, 0) = "complete" : arrFields(5, 1) = MapPoint.GeoFieldType.geoFieldData
    arrFields(6, 0) = "name" : arrFields(6, 1) = MapPoint.GeoFieldType.geoFieldData
    arrFields(7, 0) = "customerpriority" : arrFields(7, 1) = MapPoint.GeoFieldType.geoFieldData
    arrFields(8, 0) = "latitude" : arrFields(8, 1) = MapPoint.GeoFieldType.geoFieldLatitude
    arrFields(9, 0) = "logitude" : arrFields(9, 1) = MapPoint.GeoFieldType.geoFieldLongitude
    arrFields(10, 0) = "doorder" : arrFields(10, 1) = MapPoint.GeoFieldType.geoFieldData
    With objMap.DataSets
    objDS = .LinkData("test.udl!Deliveries", arrFields, MapPoint.GeoCountry.geoCountryUnitedKingdom, MapPoint.GeoDelimiter.geoDelimiterDefault)
    End With
    objDS.ZoomTo()

    End Sub
    End Class


    When I click the button I see the following errors:
    Variable 'objApp' is used before it has been assigned a value. A null reference exception could result at runtime.
    Variable 'objMap' is used before it has been assigned a value. A null reference exception could result at runtime.


    Any pointers (or tidied code) would be very much appreiciated.
    I have only ever done minimal coding in the past.

    Thanks
    Simon

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Linking to data using a UDL file (MapPoint 2006)

    Hi Simon,

    This is because of the following. If you do:
    Code:
    Dim objApp As MapPoint.Application
    Then you tell the compiler that this variable objApp is of type MapPoint.Application. But the variable contains nothing at all. So the error is correct, it is not assigned a value. You have to do something similar as:
    Code:
    objApp = CreateObject("MapPoint.Application.EU.13")
    But there is something else. You use the activeX control on your form. I dont knowin VB, but in C# it is impossible to use the activeX control in parallel with mappoint.application. But normally this is also not needed.

    All the things you wants to do with Mappoint.Application you can do with the activeX control. Check therefore:
    Code:
    AxMappointControl1.ActiveMap....
    With the .... I mean what follows there.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Opening a MP 2006 file in MP 2004, can it be done?
    By MtnDew2756 in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 08-24-2006, 08:08 PM
  2. Linking Data within an Excel Workbook to Mappoint
    By XLR Excel in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-06-2005, 02:23 PM
  3. Importing or linking data
    By alwasl8 in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 06-21-2005, 01:47 PM
  4. Linking to Weather Data From MapPoint
    By Anonymous in forum MP2K Magazine Articles
    Replies: 1
    Last Post: 11-01-2004, 08:24 AM
  5. linking to external file
    By sandiphw in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 12-18-2003, 11:34 PM

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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96