Here's some code I've used for bulk geo-coding a lot of addresses. It's basically Martin's code from the Wiki, with a typo correction and some error-checking. I found that the sample did not deal well with records that had missing address. Also since most databases will not have a field with the complete address, it adds that step. Hope this is useful.
------------------------
dim cn as sql::Connection
flag = cn.open("::Name::YOURDATABASE")
dim sql as c
'execute a query to get the primary key of each record you want to update
sql = "select ID from YOURTABLE"
cn.Execute(sql)
rs = cn.ResultSet
dim flag as l
'check to see if any rows in resultset
flag = rs.nextRow()
delete args
dim args as sql::Arguments
dim sql1 as c
' assumes you have fields latitude and longitude in your table
sql1 = "select address, city, state, country, postalcode from YOURTABLE where ID = :primaryKey"
sql2 = "update YOURTABLE set latitude = :lat, longitude = :lon where ID = :primaryKey"
dim pa as p
dim rs2 as sql::ResultSet
dim fulladdress as c
dim city as c
while flag
args.add("primaryKey",rs.data(1))
flag = cn.Execute(sql1,args)
rs2 = cn.ResultSet
fulladdress = rs2.data("address")+ "," + rs2.data("city")+ "," + rs2.data("state")+ "," + rs2.data("country")
city = rs2.data("city")
if city <> ""
pa = geocode_address(fulladdress,"Google")
args.add("lat",pa.lat)
args.add("lon",pa.lon)
flag = cn.execute(sql2,args)
end if
flag = rs.nextRow()
end while
------------------------
dim cn as sql::Connection
flag = cn.open("::Name::YOURDATABASE")
dim sql as c
'execute a query to get the primary key of each record you want to update
sql = "select ID from YOURTABLE"
cn.Execute(sql)
rs = cn.ResultSet
dim flag as l
'check to see if any rows in resultset
flag = rs.nextRow()
delete args
dim args as sql::Arguments
dim sql1 as c
' assumes you have fields latitude and longitude in your table
sql1 = "select address, city, state, country, postalcode from YOURTABLE where ID = :primaryKey"
sql2 = "update YOURTABLE set latitude = :lat, longitude = :lon where ID = :primaryKey"
dim pa as p
dim rs2 as sql::ResultSet
dim fulladdress as c
dim city as c
while flag
args.add("primaryKey",rs.data(1))
flag = cn.Execute(sql1,args)
rs2 = cn.ResultSet
fulladdress = rs2.data("address")+ "," + rs2.data("city")+ "," + rs2.data("state")+ "," + rs2.data("country")
city = rs2.data("city")
if city <> ""
pa = geocode_address(fulladdress,"Google")
args.add("lat",pa.lat)
args.add("lon",pa.lon)
flag = cn.execute(sql2,args)
end if
flag = rs.nextRow()
end while
Comment