Thursday, December 8, 2011
Microsoft Sample code
http://code.msdn.microsoft.com/
.Net Video tutorial in Tamil
http://www.youtube.com/user/reach2arunprakash/
Saturday, December 3, 2011
Bulk Upload in Sql server (using from OpenXML)
xml = "
xml += "EmpID='" + 1 + "' ";
xml += "EmpName='" + vijay + "' ";
xml += "EmpValue='" + 100 + "' />
IN SQL Server Stored Procedure:
CREATE PROCEDURE [dbo].[MyStoredProcedure]
@ActionType Varchar(20),
@XML text
AS
BEGIN
SET NOCOUNT ON
Declare @intRow int
Exec sp_xml_preparedocument @intRow Output, @xml
IF @ActionType ='Insert'
BEGIN
//Insert Query with Where condition
Insert into EmpEmployee (EmpID,EmpName,EmpValue)
Select xEmpID,xEmpName,xEmpValue
from OpenXML(@intRow,'/root/row[@Element="SaveMyData"]')
With
//Update Query with Where condition
Update EmpEmployee (EmpID=xEmpID,EmpName=xEmpName,EmpValue=xEmpValue)
End
exec sp_xml_removedocument @intRow
END
Tuesday, November 22, 2011
Windows Application Error Handling & Check Allready Application Running
In the windows entire application or while opening an application if you get any exception means the below code will help you to capture the error log. The application error or exception handling you can identify the error message. This will help you to understand the problem in your windows application using C#.Net. The below code is start up point of the win application. The program.cs class only first fire in the application.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
namespace MyProject
{
static class Program
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Control.CheckForIllegalCrossThreadCalls = true;
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
//get the name of current process, i,e the process
//name of this current application
string currPrsName = Process.GetCurrentProcess().ProcessName;
//Get the name of all processes having the
//same name as this process name
Process[] allProcessWithThisName= Process.GetProcessesByName(currPrsName);
//if more than one process is running return true.
//which means already previous instance of the application
//is running
if (allProcessWithThisName.Length > 1)
{
MessageBox.Show("The Application Already Running", "MY APP", MessageBoxButtons.OK);
Application.Exit();
// allProcessWithThisName[0].Kill();
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
else
{
frmMain mainForm = new frmMain(); //this takes ages
Application.Run(mainForm);
}
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject != null)
ErrorLog((Exception)e.ExceptionObject);
}
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
if (e.Exception != null)
ErrorLog(e.Exception);
}
}
}
Check Allready Application Running:
string currPrsName = Process.GetCurrentProcess().ProcessName;
//Get the name of all processes having the
//same name as this process name
Process[] allProcessWithThisName
= Process.GetProcessesByName(currPrsName);
//if more than one process is running return true.
//which means already previous instance of the application
//is running
if (allProcessWithThisName.Length > 1)
{
MessageBox.Show("Application Already Running", "Test", MessageBoxButtons.OK);
Application.Exit();
}
else
{
Application.Run(new frmMain());
}
-->
Friday, September 2, 2011
Adding Row in SQL SELECT Query statment
select 'Select All' as RallyNumber
union all
Select RallyNumber from MatchData
Tuesday, July 19, 2011
CSS for ASP.Net Button mouse over to change button colour
{
border-style: none;
background-color: #0079C1;
color: #FFFFFF;
font-family: arial;
font-size: 13px;
font-weight: bold;
padding-top: 4px;
padding-bottom: 4px;
/* Mozilla: */
background: -moz-linear-gradient(top, #2bc4f3, #0095da);
/* Chrome, Safari:*/
background: -webkit-gradient(linear,
left top, left bottom, from(#2bc4f3), to(#0095da));
/* MSIE < 8 */
filter: progid:DXImageTransform.Microsoft.Gradient(
StartColorStr='#2bc4f3', EndColorStr='#0095da', GradientType=0);
/* IE 8*/
-ms-filter: progid:DXImageTransform.Microsoft.gradient(
startColorstr='#2bc4f3', endColorstr='#0095da');
}
.forbuttons:hover{
background: -moz-linear-gradient(top, #0095da, #2bc4f3);
/* Chrome, Safari:*/
background: -webkit-gradient(linear,
left top, left bottom, from(#0095da), to(#2bc4f3));
/* MSIE < 8 */
filter: progid:DXImageTransform.Microsoft.Gradient(
StartColorStr='#0095da', EndColorStr='#2bc4f3', GradientType=0);
/* IE 8*/
-ms-filter: progid:DXImageTransform.Microsoft.gradient(
startColorstr='#0095da', endColorstr='#2bc4f3');
}
.forbuttons:active{
background-color:#3399FF;
color:#FFF;
}
Thursday, December 3, 2009
Friday, November 20, 2009
How to use Google Map in ASP.NET
The Javascript:
<head runat="server">
<title>Google map Page</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAA6TS6WR4jbbUjikFVO_rihBSsoQeukxbo2NPugNeooGWFf_yQhRSk4JGGBtb5COzcswcwgPpu5XJo3Q"
type="text/javascript"></script>
<script type="text/javascript">
var map=null;
var Head = 'style="color:White;background-color:#339900;font-family:Verdana;font-size:11px;font-weight:bold;"';
var Data = 'style="background-color:#ffff99;font-family:Verdana;font-size:11px;overflow:auto; "';
var gmarkers = [];
var ghtml = [];
var m = 0;
function load()
{
if (GBrowserIsCompatible())
{
var LatitudePoint='<%= LatitudePoint %>';
var LongitudePoint='<%= LongitudePoint %>';
var RestaurantName='<%= RestaurantName%>';
var RestaurantAddress='<%=RestaurantAddress%>';
var map = new GMap(document.getElementById("map"));
var point = new GPoint(LatitudePoint,LongitudePoint);
map.addControl(new GLargeMapControl());
map.setCenter(new GLatLng(LatitudePoint,LongitudePoint), 5 );
function createMarker(point,Html)
{
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function()
{
//marker.openInfoWindowHtml('<div class="infodescription">'+Html+'</div>');
marker.openInfoWindowHtml(Html);
});
return marker;
}
var request = GXmlHttp.create();
request.open("GET", "parks.xml", true);
request.onreadystatechange = function()
{
if (request.readyState == 4)
{
var xmlDoc = request.responseXML;
var points = xmlDoc.documentElement.getElementsByTagName("park");
for (var i = 0; i < points.length; i++)
{
var point = new GPoint(LongitudePoint,
LatitudePoint);
var cHtml = '<table cellspacing=0 cellpading=0 border=1>' +
'<tr>' +
'<td align="center">' + RestaurantName + '</td>' +
'</tr>'+
'<tr>' +
'<td>' + RestaurantAddress + '</td>' +
'</tr>' +
'</table>';
var marker = createMarker(point,cHtml);
map.addOverlay(marker);
marker.openInfoWindowHtml(cHtml);
}
}
}
request.send(null);
}
}
</script>
</head>
<body onload="load()">
<form id="form1" runat="server">
<div>
<div id="map" style="width: 700px; height: 590px;">
</div>
</div>
</form>
</body>
The XML File: (parks.xml)
<parks>
<park FullName="Test" address="8,GN Road" lng="80.2385401725769" lat="13.048898223457536"/>
<park FullName="Birds Fort Trail Park" address="575 North Usman Road" lng="80.2496401725769" lat="13.059898223457536"/>
</parks>
Asp.Net C# Coding:
public string LatitudePoint = "12.916051";
public string LongitudePoint = "80.024414";
public string RestaurantName = "Rangish";
public string RestaurantAddress = "";
public string strRestaurantID = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
LatitudePoint = "70.5896";
LongitudePoint = "80.2568";
RestaurantName = "Test Name";
RestaurantAddress = "Dharapuram";
}
}