MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




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 2006/2009 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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (3) Thread Tools Display Modes
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 02-19-2007
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 02-19-2007
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
data, file, linking, mappoint 2006, udl


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/linking-data-using-udl-file-mappoint-2006-a-5688.html

Posted By For Type Date
Microsoft MapPoint 2006 - MP2K Magazine This thread Refback 02-28-2007 08:47 AM
CRITERION CORPORATION - Company Directory - MP2K Magazine This thread Refback 02-23-2007 06:54 AM
Programming MapPoint in .NET - MP2K Magazine This thread Refback 02-20-2007 10:11 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

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


All times are GMT -5. The time now is 10:40 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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