Thursday, October 23, 2008

India Australia 2nd Test , Mohali, Australia staring @ defeat




In Mohali Australia were staring at defeat after losing their top five batsmen for just 10 runs on the fourth day of the second Test against India here on Monday.
Chasing a huge victory target of 516 after the Indians declared their second innings at 314-3, Australia were struggling at 141-5 at stumps at the Punjab Cricket Association.

Michael Clarke however defied the Indian attack and was on 42 with six fours at close along with Brad Haddin (37), both having put on 83 runs for the sixth-wicket stand. Off-spinner Harbhajan Singh, 28, started the Australian rot, sending back openers Matthew Hayden (29) and Simon Katich (20) in his sensational opening over before removing Michael Hussey (one) for his 299th Test scalp.
Hayden, who hit Zaheer Khan for two fours in an over, was trapped leg before while Katich lobbed one for Sachin Tendulkar to take a fine tumbling catch at short point.
Ricky Ponting (two) saw his off-stump uprooted by lanky paceman Ishant Sharma who claimed the Australian skipper for the fifth time in as many matches.
Sharma then returned to dismiss Shane Watson (two), who top-scored with 78 in Australia’s first innings total of 268, to reduce Australia to 58-5.



Needing 375 more runs with five wickets in hand, the number one side in the world will have to pray for a miracle if they are to stop India from going 1-0 up in the series for the Border-Gavaskar trophy.History is also against the visitors as the highest successful fourth innings chase is 418 achieved by the West Indies against Australia at St. John’s in the 2002-03 series.
Australian coach Tim Nielsen though believed his team could still pull off a win, declaring “the game is not lost yet.”
“The whole day is left tomorrow and it’s a nice batting wicket. We just need to make sure we execute our skills better.

Chandrayaan to be launched on October 22


India's maiden lunar mission, the Chandrayaan-1 spacecraft that launches on October 22, will orbit about 100 km from the lunar surface for two years, performing remote sensing of the dark side or hidden portion of the moon to unravel its mysteries, scientists working on the project said. About 500 space scientists are working round-the-clock to launch India's maiden lunar mission next week.


The Chandrayaan-1 spacecraft will be launched on board the Polar Satellite Launch Vehicle (PSLV) C11 from the Satish Dhawan Space Centre (SDSC) in Sriharikota, about 90 km from Chennai and off the Bay of Bengal.

"Moon is the nearest celestial body to earth at a distance of 384,000 km. Formation and evolution of moon are central to understanding the solar system. Though there have been many manned and unmanned lunar explorations, Chandrayaan will be the first spacecraft to explore the dark side or hidden portion of moon and unravel the mystery behind," SDSC deputy director M S N Prasad said at a demo of the lunar mission.

According to ISRO director S Satish, the lunar mission is estimated to cost about Rs.3.86 billion ($80 million), including Rs.1 billion for the launch vehicle, Rs.1 billion for the Deep Space Network (DSN) near Bangalore to receive the radio signals transmitted by Chandrayaan and Rs.1.86 billion for the spacecraft, sub-systems and other components, including payloads.



Chandrayaan Antina To Recieve Signals

Wednesday, September 10, 2008

DB BackUp for per day schedule






PERFORMING DB BACKUP OPERATION USING TWO LINES QUERY


1. Create a SP to Back Up entireDatabase
TestingDB is the name of Database for which backup is formed and BackUp.bak is the backup file which will create when u will run query and D:\\ simply Disk Location.
BACKUP Database TestingDB
TO DISK = 'D:\BackUp.bak'
WITH Format

Go
2. Open vs and create a project (Console Application).
write code to call sp in Program.cs for example

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Net.Mail;
namespace CMS_BACKUP
{
class Program
{
static void Main(string[] args)
{
CallBackUpDataBase();
}
private static void CallBackUpDataBase()
{
SqlConnection myConn=null;
try
{
SqlCommand cmd;
myConn = new SqlConnection("Data Source=;Initial Catalog=;User ID=sa;Password= ");
myConn.Open();
cmd = new SqlCommand("Back_Up_CMS", myConn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{ }
finally
{
myConn.Close();
}
}
}
}
3. Build project to create exe. exe will create in Debug folder of Solution.
4. Now you can create a window service by using Schedule Task to schedule your exe.

Thursday, September 4, 2008

Create Shedular as window service and Code to Send Mail

-------------------Scheduler to Send mail---------------------

1. create a console Application using VS. Write Code in Code file as mentioned



Program.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Net.Mail;
namespace DFIDSchedular
{
class Program
{
static void Main(string[] args)
{
// get all the contract whose end date is after 15 days
GetContractsDetails(16);
// get all the contract whose end date is after 7 days
GetContractsDetails(8);
// get all the contract whose end date is after 3 days
GetContractsDetails(4);
// get all the contract whose end date today
UpdateContractsStatus();
}
private static void UpdateContractsStatus()
{
SqlConnection myConn=null;
try
{
SqlCommand cmd;
myConn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
myConn.Open();
cmd = new SqlCommand("UpdateContractStatus", myConn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{ }
finally
{
myConn.Close();
}
}
private static void GetContractsDetails(int Days)
{
SqlConnection myConn;
SqlDataAdapter myAdap;
SqlDataAdapter myAdap1;
DataSet myDataSet;
DataSet myDataSet1;
SqlCommand cmd;
SqlCommand cmd1;
string body = string.Empty;
string MailTo = string.Empty;
//get the connection string from the database
myConn = new SqlConnection(ConfigurationManager.AppSettings["DFIDConnectionString"]);
cmd = new SqlCommand("GetContracts", myConn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@NoOfDays", SqlDbType.Int);
cmd.Parameters[0].Value = Days;
myAdap = new SqlDataAdapter(cmd);
myDataSet = new DataSet();
myAdap.Fill(myDataSet);

//To see information
FileInfo t = new FileInfo("c:\\Collin.txt");
StreamWriter Tex = t.CreateText();
Tex.WriteLine("MailTo");
Tex.WriteLine("AAAAAAA");
Tex.WriteLine("body");
Tex.Write(Tex.NewLine);
Tex.Close();
Console.WriteLine(" The Text file named Collin is created ");
//end

for (int iCount = 0; iCount < contractcode="string.Empty;" contracttitle="string.Empty;" enddate="string.Empty;" contractofficer="string.Empty;" contractcode="myDataSet.Tables[0].Rows[iCount][" contracttitle="myDataSet.Tables[0].Rows[iCount][" enddate="myDataSet.Tables[0].Rows[iCount][" cmd1 =" new" commandtype =" CommandType.StoredProcedure;" value =" myDataSet.Tables[0].Rows[iCount][" myadap1 =" new" mydataset1 =" new" mailto1 =" new"> 0)
{
if (myDataSet1.Tables[0].Rows[0]["Email_Id"].ToString()!= "not-applicable")
{
MailTo = myDataSet1.Tables[0].Rows[0]["Email_Id"].ToString() + "@" + ConfigurationManager.AppSettings["Email"].ToString();
}
}
if (myDataSet1.Tables[1].Rows.Count > 0)
{
if (myDataSet1.Tables[1].Rows[0]["Email_Id"].ToString()!= "not-applicable")
{
MailTo = MailTo + "," + myDataSet1.Tables[1].Rows[0]["Email_Id"].ToString() + "@" + ConfigurationManager.AppSettings["Email"].ToString();
}
}
if (myDataSet1.Tables[2].Rows.Count > 0)
{
if (myDataSet1.Tables[2].Rows[0]["Email_Id"].ToString()!= "not-applicable")
{
MailTo =MailTo+","+ myDataSet1.Tables[2].Rows[0]["Email_Id"].ToString() + "@" + ConfigurationManager.AppSettings["Email"].ToString();
}
}
if (myDataSet1.Tables[3].Rows.Count > 0)
{
if (myDataSet1.Tables[3].Rows[0]["Email_Id"].ToString()!= "not-applicable")
{
MailTo = MailTo + "," + myDataSet1.Tables[3].Rows[0]["Email_Id"].ToString() + "@" + ConfigurationManager.AppSettings["Email"].ToString();
}

}
if (myDataSet1.Tables[4].Rows.Count > 0)
{
if (myDataSet1.Tables[4].Rows[0]["Email_Id"].ToString()!= "not-applicable")
{
ContractOfficer=myDataSet1.Tables[4].Rows[0]["Name"].ToString();
MailTo = MailTo + "," + myDataSet1.Tables[4].Rows[0]["Email_Id"].ToString() + "@" + ConfigurationManager.AppSettings["Email"].ToString();

}
}
MailMessage message = new MailMessage();
message.IsBodyHtml = true;
message.From = new MailAddress(ConfigurationManager.AppSettings["EmailFrom"]);
if (MailTo != null && MailTo != "")
{
message.To.Add("harisht@enterpriseinfotech.com");
if (Days != 3)
{
message.Subject = ContractCode + " - Contract Expiry Alert";
body = "Contract Code " + ContractCode + " - " + ContractTitle + " is ending on " + EndDate + ". Should this require an extension or amendment please contact http://10.20.0.25/login.asp. " + ContractOfficer + " .";
}
else
{
message.Subject = ContractCode + " - Performance Evaluation ";
body = "Contract Code " + ContractCode + " - " + ContractTitle + " is ending on " + EndDate + ". Please complete a Performance Evaluation form on CMS http://10.20.0.25/login.asp." +
"Please contact CaPAS for further guidance if required.";
}

message.Body = body;
//FileInfo t = new FileInfo("c:\\Collin.txt");
//StreamWriter Tex = t.CreateText();
//Tex.WriteLine(MailTo);
//Tex.WriteLine(message.Subject);
//Tex.WriteLine(body);
//Tex.Write(Tex.NewLine);
//Tex.Close();
Console.WriteLine(" The Text file named Collin is created ");
SmtpClient emailClient = new SmtpClient(ConfigurationManager.AppSettings["MailServer"]);
System.Net.NetworkCredential cred = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"]);
emailClient.Credentials = cred;
emailClient.Send(message);
MailTo = "";
}
}
}
}
}










--------------------------App.Config File------------------------

Setting in AppSetting tag



add key="DFIDConnectionString" value="Data Source=SUMIT;Initial Catalog=cms; User ID=sa;Password=pass@word1"
add key="Email" value=" "
add key="MailServer" value=" "
add key="UserName" value="mailto:value=Harisht@gmail.com"
add key="Password" value="ramayan"
add key="EmailFrom" value="mailto:value=Harisht@gmail.com"



--------------------------------------------------------------------------------







Now Run the project this will create a .exe file in Bin-->Debug-->Sheduler.exe .


Copy this .exe file and then schedule to it in windows services to send mail alerts.


----------------------------------------------------------------------------------------





2. How to Schedule .exe in windows servvices


open program--> Accessories -->SystemTools --> Schedule Task


Now click on Add Sheduled Task.
.











Now Click On Next. next Screen will Appear as following




Now Click On Browse to get your .exe File.





Now Click On Open next screen will be .





Now Click On Option button to perform task Daily,monthly,Weekly etc and click on Next .





Now Set the start date and time and click next




Set the Password and click next




Now click on Finish your task has been scheduled in window services.

How to Export Data from Excel 2007 to Sql Server



1. Open MS Access and select database you want to export.
2. select database tool from menu bar. then you will see screen as below.
3. click next to create a new Data base.
4.on next screen enter credentials for sql server.
5.press Next .
The above procedure export your data base in Sql Server.