public void TrackUsers() { var locationService = new GoogleLocationService(); var ip = Request.ServerVariables["REMOTE_ADDR"];; IpInfo ipinfo = GetUserCountryByIp(ip); if (ipinfo.Loc != null) { string[] latlong = ipinfo.Loc.Split(','); ipinfo.Loc = clsobj.GetAddressFromLatLong(Convert.ToDouble(latlong[0]), Convert.ToDouble(latlong[1])); } SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_InsertTrackRecord"; cmd.Connection = conn; cmd.Parameters.AddWithValue("@Ip", ipinfo.Ip == null ? "" : ipinfo.Ip); cmd.Parameters.AddWithValue("@Hostname", ipinfo.Hostname == null ? "" : ipinfo.Hostname); cmd.Parameters.AddWithValue("@City", ipinfo.City == null ? "" : ipinfo.City); cmd.Parameters.AddWithValue("@Region", ipinfo.Region == null ? "" : ipinfo.Region); cmd.Parameters.AddWithValue("@Country", ipinfo.Country == null ? "" : ipinfo.Country); cmd.Parameters.AddWithValue("@Loc", ipinfo.Loc == null ? "" : ipinfo.Loc); cmd.Parameters.AddWithValue("@Org", ipinfo.Org == null ? "" : ipinfo.Org); cmd.Parameters.AddWithValue("@Postal", ipinfo.Postal == null ? "" : ipinfo.Postal); if (conn.State == ConnectionState.Closed) { conn.Open(); } cmd.ExecuteNonQuery(); }