How do I loop through a dataset or sql table and map points on a google map?

Hi, I am very new to C# and I am trying to create a loop and create Google map points. Via a dataset or SQL table. I have read a lot of blogs, they all seem to show hard coded lat and long. I need to dynamically be able to plot those points. IE whether it be one or 1000 points. Please help. I understand how the map works. Just Can't get the data from my database into a workable loop function to create points. Can some please help me!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

From the onload event of <body> tag, call a javascript function to initialize the map object. Then call the loadMapPoints function. The javascript function loadMapPoints is created dynamically from the database table.

//following code will loop through a datatable and prepare a javascript to add map points.
StringBuilder strMapPoints = new StringBuilder();
DataTable tb;
//populate the table tb declared above
Int32 index = 0;
foreach (DataRow dr in tb.Rows)
                strMapPoints.Append("var mapPoint" + index.ToString() + " = new google.maps.Marker({map: map, position: new google.maps.LatLng(" + dr["lat"].ToString() + "," + dr["lon"].ToString() + ")});");
                index += 1;
//add a label lblScript just before the closing </form> tag.
lblScript.Text = "<script> function loadMapPoints(){ " + strMapPoints.ToString() + "}</script>";

It works for me.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crmcITAuthor Commented:
I'm not sure how to populate the Datatabel from an SQL Database here. Do you have an example you could share?  Also not familiar with Java yet. Can you explain what you ment by Funciton LoadMapPoints.
crmcITAuthor Commented:
Not all the detail was there that I need to complet my task!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.