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.LoadAxMappointControl1.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.ClickDim 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.DataSetsobjDS = .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