PDA

View Full Version : Refresh SQL data



tkroljic
10-05-2011, 01:53 PM
All,
New to MapPoint and this forum. I'm using version 2010. I added the SQL Server Addin to my MapPoint application. I'm able to use the SQL addin to make a Connection and add data to MapPoint via a Layer from my SQL data (we are running SQL Server 2008 R2). My SQL table contains three columns: one for Latitude, one for Longitude, and a third for the calculated Geometry Point value of the Lat/Lng.

My question has to do with refreshing the data. Ideally I'd like to give this MapPoint file to an Enduser. I was under the impression that since I'm using a connection to our SQL server, that whenever the user opens the MapPoint file, they would see the latest data (either a change to an address or new address records). It does appear to do so.

Do I need to have the user click on a "refresh" button or something? Is there a setting in the SQL addin that would refresh the data when the application opens.

Do I need to create some vba code that executes when the MapPoint opens to refresh the SQL addin.

If there is any documentation that discuss how to do this, just let me know where this is and I'll do some reading.

Any help would be greatly appreciated.

Thanks,
Thomas

tkroljic
10-06-2011, 08:58 AM
I was able to 'refresh' the data by right clicking on the Layer and selecting Refresh Map.

If there a way to automate this step? Can I use VBA code to open the SQL server Addin and then refresh the map? Is so, is it best to use something like vb.net or Access or Excel to develop the vba code and then launch MapPoint? Or can this (vba code) be embedded within MapPoint?

Thank you,
Thomas

Eric Frost
10-06-2011, 09:06 AM
That SQL Server add-in does not come with source code, so to automate it you'd be stuck trying to do things with SendKeys or WinBatch. Kludgy but if it works it works.

Otherwise you could scrap the SQL server add-in and write your own connection and rendering tool. Richard and I wrote an article for MSDN last year which discusses an approach for doing this. The article is available free online --
SQL Server and MapPoint - Making MapPoint 2010 and SQL Server Spatial Work Together (http://msdn.microsoft.com/en-us/magazine/ff959816.aspx)

Eric

tkroljic
10-06-2011, 09:08 AM
Eric,
Thank you very much for replying to me call for help. I will read your article and give it a try. I really appreciate the link and advice.

Thomas

Eric Frost
10-06-2011, 09:44 AM
Unless there's some other compelling reason to write your own importer, it's probably most practical to just include instructions for the end-user to refresh manually?

Eric

tkroljic
10-06-2011, 09:54 AM
Eric,
We have several users/volunteers who would be using MapPoint 2010 to access the data on our SQL servers. We are a non-profit organization called "Philabundance". We are the largest food bank in the Philadelphia area. Our users use MapPoint when a person calls us looking for the nearest location to where they can get some food. Our users will open up a MapPoint file that contains the location of food cupboards in the Philadelphia area, enter the persons address, and then begin to see what food cupboards are located within a short distance. All the Food Cupboards' addresses are stored in our SQL database. This information does change. Not that frequently, but it does change. We ideally do not want to have to train our users to "refresh" the data as these folks are volunteers and change often. I was hoping that by using the SQL Addin, it would display the latest data whenever the user opens up the MapPoint file.
If writing a vb.net app with MapPoint embedded into a windows form isn't that difficult, then maybe that is the route I should take. Are you saying that creating a .net application that connects back to SQL, and uses MapPoint is complex? Not worth the time and resources? Do you have any other suggestions that might help me out? We do have a higher end application called ArcGIS but I think that might be overkill for what we would like to do. But maybe ArcGIS is the way to go.

Thanks,
Thomas

Eric Frost
10-06-2011, 10:10 AM
If writing a vb.net app with MapPoint embedded into a windows form isn't that difficult, then maybe that is the route I should take.

Great, yeah it's not that difficult. It might be even easier not to embed MapPoint in the form, just instantiate and automate it.


Are you saying that creating a .net application that connects back to SQL, and uses MapPoint is complex?

Depends on your skill and ambition, but I hope that article helps! Part of the effort might be deployment if you have old computers, be sure to test on a few of them before you get too far in the process.

Eric

Eric Frost
10-06-2011, 10:13 AM
We do have a higher end application called ArcGIS but I think that might be overkill for what we would like to do. But maybe ArcGIS is the way to go.

I don't know about licensing costs for ArcGIS, but when you are talking about several users, it might add up quickly. MapPoint retails for $299 per user and we sell it for $224 which I believe is the lowest cost anywhere (besides academic).

Eric

tkroljic
10-06-2011, 10:13 AM
Eric,
<<just instantiate and automate it>>
Yeah, I was kind of thinking the same thing.
So, it looks like I'll spend a little time developing a vb.net app that instantiates MapPoint and I'll see how far I go.

I appreciate your advice. I'll update this thread as I get more into the development process.

Do you know of any good books or website for MapPoint 2010?

Thanks
Thomas

Eric Frost
10-06-2011, 10:22 AM
MapPoint for Dummies and Programming MapPoint in .NET both have code samples. We sell both MapPoint 2011 North America, MapPoint 2011 Europe, Pushpin Tool, MapPoint for Dummies, Programming MapPoint in .NET (http://www.mapforums.com/mappoint.php)

MapPoint for dummies has VBA code and Programming MapPoint in .NET has C# code, but both are useful as instruction on how to work with the MapPoint API. I think Programming MapPoint in .NET is particularly good for showing how to use the DisplayDataMap method, which can be troublesome.

Also, it wouldn't hurt to peruse the articles on MP2Kmag.com/articles.asp, there are lots of good ones.

The MapPoint help file is really good and has both VB and C# code.

The MapForums Downloads section ($99) has tons of different working tools with source code.

Finally, search this forum e.g.
site:mapforums.com Philabundance - Google Search (http://www.google.com/search?q=site%3Amapforums.com+Philabundance)

Eric

tkroljic
10-06-2011, 10:29 AM
Eric,
Thanks for the great information. I think we might have a copy of <<Programming MapPoint in .NET>> somewhere in our office. I'll have to find this book and take a look inside.

I'll give you an update in a few days via this thread.

Thanks
Thomas