This is my technical area for troubleshooting and learning new programming skills and much more. Here, you will find answers on a wide range of technologies such as AI, Machine Learning, OpenAI, Databricks, ASP.NET, C#, Python, Microsoft Access, MySQL, Amazon Web Services, SQL Server, PL/SQL, JD Edwards, SAS, Salesforce, APIs, MVC, and many others. Please feel free to visit and join the discussion!
Wednesday, November 17, 2010
Get a facebook email address
MAC and Xcode in Windows iPod, iPhone and iPad
Tuesday, November 16, 2010
Validation (XHTML 1.0 Transitional): Element 'video' is not supported. html5
Google map api total distance and duration calculation C#
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load("http://maps.googleapis.com/maps/api/directions/xml?origin=92610&destination=92630&sensor=false");
XmlNodeList xnList = xDoc.SelectNodes("DirectionsResponse/route/leg/distance");
foreach (XmlNode xn in xnList)
{
Response.Write("distance-> "+xn["text"].InnerText);
}
XmlNodeList xnList1 = xDoc.SelectNodes("DirectionsResponse/route/leg/duration");
foreach (XmlNode xn in xnList1)
{
Response.Write("<br>duration-> " + xn["text"].InnerText);
}
}
Monday, November 15, 2010
Comma Delimited value in sql-server where condition
DECLARE
@psCSString VARCHAR(1000)set
@psCSString='123,456,789,0123,dsdsd'create
table #otTemp (fld varchar(20)) WHILE LEN(@psCSString) > 0 BEGIN SET @sTemp = LEFT(@psCSString, ISNULL(NULLIF(CHARINDEX(',', @psCSString) - 1, -1), LEN(@psCSString))) SET @psCSString = SUBSTRING(@psCSString,ISNULL(NULLIF(CHARINDEX(',', @psCSString), 0), LEN(@psCSString)) + 1, LEN(@psCSString))INSERT
INTO #otTemp VALUES (@sTemp)--drop table #otTemp
--select @sTemp
END select * from dshsjh in( select * from #otTemp) drop table #otTempParsing string variable in Where clause with commas
string variable in Where clause with commas
DECLARE @sTemp VARCHAR(1000)
DECLARE @psCSString VARCHAR(1000)
set @psCSString='dsdss,dsdd,sddsds,43443,dsdsd'
WHILE LEN(@psCSString) > 0
BEGIN
SET @sTemp = LEFT(@psCSString, ISNULL(NULLIF(CHARINDEX(',', @psCSString) - 1, -1),
LEN(@psCSString)))
SET @psCSString = SUBSTRING(@psCSString,ISNULL(NULLIF(CHARINDEX(',', @psCSString), 0),
LEN(@psCSString)) + 1, LEN(@psCSString))
-- INSERT INTO @otTemp VALUES (@sTemp)
select @sTemp
END
Split parameter string from comma seperator in SQL IN clause
Thursday, November 11, 2010
Wednesday, November 10, 2010
Call Javascript from code behind c# sample
Google map API distance C# javascript calling from code behind
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default10.aspx.cs" Inherits="Default10" %>
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API Example: Extraction of Geocoding Data</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7j_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"></script>
<!-- According to the Google Maps API Terms of Service you are required display a Google map when using the Google Maps API. see: http://code.google.com/apis/maps/terms.html -->
<script type="text/javascript">
var geocoder, location1, location2;
function showLocation() {
geocoder = new GClientGeocoder();
geocoder.getLocations(document.forms[0].address1.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the first address");
}
else
{
location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
geocoder.getLocations(document.forms[0].address2.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the second address");
}
else
{
location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
calculateDistance();
}
});
}
});
}
function calculateDistance()
{
try
{
var glatlng1 = new GLatLng(location1.lat, location1.lon);
var glatlng2 = new GLatLng(location2.lat, location2.lon);
var miledistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);
var kmdistance = (miledistance * 1.609344).toFixed(1);
//document.getElementById('results').innerHTML = '<strong>Address 1: </strong>' + location1.address + '<br /><strong>Address 2: </strong>' + location2.address + '<br /><strong>Distance: </strong>' + miledistance + ' miles (or ' + kmdistance + ' kilometers)';
document.getElementById("Label1").innerHTML = '<strong>Address 1: </strong>' + location1.address + '<br /><strong>Address 2: </strong>' + location2.address + '<br /><strong>Distance: </strong>' + miledistance + ' miles (or ' + kmdistance + ' kilometers)';
}
catch (error)
{
alert(error);
}
}
</script>
</head>
<body>
<form id="wedkj" runat="server">
<p>
<input type="text" name="address1" value="92610" class="address_input"
size="40" />
<input type="text" name="address2" value="92679" class="address_input"
size="40" />
<input type="submit" name="find" value="Search" />
</p>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default10 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Label1.Text = inpHide.Value;
// Response.Write(Label1.innerHtml);
//Response.Write("dsdsdsd");
// Response.Write(Label2.Text);
}
protected void Button1_Click(object sender, EventArgs e)
{
//Response.Write("1111dssddsddsdssd");
Button1.Attributes.Add("onclick", "showLocation(); return false;");
}
protected void Button2_Click(object sender, EventArgs e)
{
//Response.Write(Label1.Text);
}
}
Friday, November 5, 2010
Yahoo map/geocoding API to get latitude and longitude c# sample
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class yalatilongi : System.Web.UI.Page
{
private GeoAddressAPI geoAPI = new GeoAddressAPI();
protected void Page_Load(object sender, EventArgs e)
{
string strConnection = "server=xxxxx;database=xxxxx;uid=sa;pwd=xxxxxxx;Connect Timeout=60";
SqlConnection myConn = new SqlConnection(strConnection);
string strstate = "CA";
string query = "select aladd1,alcty1,aladds,aladdz,aban8 from jde_rk.dbo.latlongad where lati=0 and aladds='"+strstate+"'";
SqlCommand myCommand = new SqlCommand(query, myConn);
myCommand.Connection.Open();
SqlDataReader myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
Response.Write(myReader.GetString(0));
Response.Write("<br>");
Response.Write(myReader.GetString(1));
Response.Write("<br>");
Response.Write(myReader.GetString(2));
Response.Write("<br>");
Response.Write(myReader.GetString(3));
Response.Write("<br>");
Response.Write(myReader.GetString(4));
Response.Write("<br>");
GeoAddress address = geoAPI.GeoEncodeAddress(myReader.GetString(0), myReader.GetString(1), myReader.GetString(2), myReader.GetString(3));
Response.Write(address.Latitude);
Response.Write("<br>");
Response.Write(address.Longitude);
Response.Write("<br>");
Response.Write(myReader.GetString(4));
// Response.End();
editLeadMaster(myReader.GetString(4), address.Latitude, address.Longitude);
}
myReader.Close();
myConn.Close();
}
void editLeadMaster(string aban8, string Lati, string Longi)
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
string strSQL = "UPDATE jde_rk.dbo.latlongad SET longi=@longi,lati=@lati WHERE aban8 ='" + aban8 + "'";
SqlCommand cmd = new SqlCommand(strSQL, myConnection);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@longi", Longi.ToString());
cmd.Parameters.AddWithValue("@lati", Lati.ToString());
myConnection.Open();
cmd.ExecuteNonQuery();
myConnection.Close();
}
private string ConnectionString
{
get
{
string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
return connectionString;
}
}
}
for distance calculation use following:-
private double distanceCal(double Lat1, double Long1, double Lat2, double Long2, char unit)
{
double dDistance = Double.MinValue;
double dLat1InRad = Lat1 * (Math.PI / 180.0);
double dLong1InRad = Long1 * (Math.PI / 180.0);
double dLat2InRad = Lat2 * (Math.PI / 180.0);
double dLong2InRad = Long2 * (Math.PI / 180.0);
double dLongitude = dLong2InRad - dLong1InRad;
double dLatitude = dLat2InRad - dLat1InRad;
// Intermediate result a.
double a = Math.Pow(Math.Sin(dLatitude / 2.0), 2.0) + Math.Cos(dLat1InRad) * Math.Cos(dLat2InRad) * Math.Pow(Math.Sin(dLongitude / 2.0), 2.0);
// Intermediate result c (great circle distance in Radians).
double c = 2.0 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1.0 - a));
// Distance.
// const Double kEarthRadiusMiles = 3956.0;
const Double kEarthRadiusKms = 6376.5;
dDistance = kEarthRadiusKms * c;
return dDistance;
//return (dist);
}
Wednesday, November 3, 2010
Put Double quotes in excel data
| 2063719971 | "2063719971", | " | ", | |||
| 2063719997 | "2063719997", | " | ", | |||
| 2063720425 | "2063720425", | " | ", | |||
| 2063720466 | "2063720466", | " | ", | |||
| 2063720789 | "2063720789", | " | ", | |||
| 2063720797 | "2063720797", | " | ", |