Tuesday, August 18, 2009

Sample Convert Number to Hours, Minutes in SQL Server

Convert Number to Hours and Minutes in SQL Server
SELECT pntotim/60 " hours ", pntotim % 60 " minutes" ,* FROM sATINOUT

Monday, August 17, 2009

Calculate Date Time difference in asp.net c#

Calculate Date time difference in asp.net c#
 
TimeSpan tmspan = DateTime.Parse(DateTime.Now.ToString()).Subtract(DateTime.Parse(YourTime.Text));

Response.Write(tmspan.Hours);

Response.Write("<br>");

Response.Write(tmspan.Minutes);

Response.Write("<br>");

Response.Write(tmspan.TotalHours);

Response.Write("<br>");

Response.Write(tmspan.TotalMinutes);

Friday, August 14, 2009

Retrieving Data Using the DataReader C# Asp.net

void loaddata()
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
char stus = "N";
string strSQL = "select * FROM sATINOUT WHERE PNEMPID=" + Session["Udid"] + " and PNSTUS=" + stus;
SqlCommand cmd = new SqlCommand(strSQL, myConnection);
myConnection.Open();
SqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
if (myReader.HasRows)
{
while (myReader.Read())
{
TxtUSERid.Text = myReader["UDUSRID"].ToString();
txtpasswd.Text = myReader["UDPASSWD"].ToString();
}
}
myReader.Close();
myConnection.Close();
}


Retrieving Data Using the DataReader