Google Map error: object reference not set to an instance of an object in ASP.Net

Last Reply one year ago By nauna

Posted one year ago


i am using following code of google map but some times it gives error object reference not set to an instance of an object



string url = "" + Request.QueryString["to"].ToString() + "&sensor=false";
            WebRequest request = WebRequest.Create(url);
            using (WebResponse response = (HttpWebResponse)request.GetResponse())
                using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
                    DataSet dsResult = new DataSet();
                    DataTable dtCoordinates = new DataTable();
                    dtCoordinates.Columns.AddRange(new DataColumn[4] { new DataColumn("Id", typeof(int)),
                        new DataColumn("Address", typeof(string)),
                        new DataColumn("Latitude",typeof(string)),
                        new DataColumn("Longitude",typeof(string)) });
                    foreach (DataRow row in dsResult.Tables["result"].Rows)
                        string geometry_id = dsResult.Tables["geometry"].Select("result_id = " + row["result_id"].ToString())[0]["geometry_id"].ToString();
                        DataRow location = dsResult.Tables["location"].Select("geometry_id = " + geometry_id)[0];
                        dtCoordinates.Rows.Add(row["result_id"], row["formatted_address"], location["lat"], location["lng"]);

                        Label6.Text = location["lat"].ToString();

                        Label7.Text = location["lng"].ToString();



You are viewing reply posted by: nauna one year ago.
Posted one year ago

it was my network error the api is ok thanks