Anonymous
10-14-2004, 08:13 AM
Hi,
I am a complete beginner (2 weeks learning) and I'm trying to create a map with multiple pushpins with their attributes based on data read from a database however it doesnt seem to work, the code I am using is below, if anyone knows how to fix this or a better method (with example code) I would be extremely grateful.
Thanks,
Note: I have got all the other map attributes eg. mapoptions etc, I have just included the relevant code here.
Dim Conn As OleDbConnection
Dim Cmd As OleDbCommand
Dim strSql As String
Dim reader As OleDbDataReader
Dim i As Integer
Dim t As Integer
t = 0
i = 0
Conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("loneworkers.mdb"))
Cmd = New OleDbCommand(strSql, Conn)
strSql = "SELECT * FROM TableName"
Cmd = New OleDbCommand(strSql, Conn)
Try
Conn.Open()
reader = Cmd.ExecuteReader()
'Loop through the returned records
While reader.Read()
i = i + 1
t = t + 1
Dim latlongs(i) As LatLong
latlongs(i) = New LatLong
latlongs(i).Latitude = reader("UpdateLocationX").ToString()
latlongs(i).Longitude = reader("UpdateLocationY").ToString()
Dim myPushPins(t) As Pushpin
myPushPins(t) = New Pushpin
myPushPins(t).Label = reader("firstname").ToString() & " " & reader("surname").ToString()
myPushPins(t).IconName = t
myPushPins(t).IconDataSource = "MapPoint.Icons"
myPushPins(t).LatLong = latlongs(i)
End While
'Close the reader object
reader.Close()
I am a complete beginner (2 weeks learning) and I'm trying to create a map with multiple pushpins with their attributes based on data read from a database however it doesnt seem to work, the code I am using is below, if anyone knows how to fix this or a better method (with example code) I would be extremely grateful.
Thanks,
Note: I have got all the other map attributes eg. mapoptions etc, I have just included the relevant code here.
Dim Conn As OleDbConnection
Dim Cmd As OleDbCommand
Dim strSql As String
Dim reader As OleDbDataReader
Dim i As Integer
Dim t As Integer
t = 0
i = 0
Conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("loneworkers.mdb"))
Cmd = New OleDbCommand(strSql, Conn)
strSql = "SELECT * FROM TableName"
Cmd = New OleDbCommand(strSql, Conn)
Try
Conn.Open()
reader = Cmd.ExecuteReader()
'Loop through the returned records
While reader.Read()
i = i + 1
t = t + 1
Dim latlongs(i) As LatLong
latlongs(i) = New LatLong
latlongs(i).Latitude = reader("UpdateLocationX").ToString()
latlongs(i).Longitude = reader("UpdateLocationY").ToString()
Dim myPushPins(t) As Pushpin
myPushPins(t) = New Pushpin
myPushPins(t).Label = reader("firstname").ToString() & " " & reader("surname").ToString()
myPushPins(t).IconName = t
myPushPins(t).IconDataSource = "MapPoint.Icons"
myPushPins(t).LatLong = latlongs(i)
End While
'Close the reader object
reader.Close()