Convert Date from any format to any format
I came across some problem while converting dates in C# between dd/mm/yyyy and mm/dd/yyyy.
Was struggling with this for a long time and got it in one of the sites. here is the solution :
You can change the from to format and see your results.
Courtesy : Kushaal.net
//For ex., Convert MM/dd/YYYY to dd/MM/yyyy
string date = "03/27/2008"; //format is MM/dd/yyyy
DateTimeFormatInfo dateTimeFormatterProvider = DateTimeFormatInfo.CurrentInfo.Clone() as DateTimeFormatInfo;
dateTimeFormatterProvider.ShortDatePattern = "MM/dd/yyyy"; //source date format
DateTime dateTime = DateTime.Parse(date, dateTimeFormatterProvider);
string formatted = dateTime.ToString("dd/MM/yyyy"); //write the format in which you want the date tobe converted
Response.Write("
" + formatted);
Sunday, March 8, 2009
Friday, March 6, 2009
Return datatable from Data logic layer in .net C#
One of my frenz asked how to return a datatable today
so i sent a code for him
posting the same here
public DataTable functionname()
{
DataTable dt = new DataTable();
DataSet ds = new DataSet();
ds = sqlhelper.ExecuteDataSet(strconnectionstring,CommandType.StoredProcedure,"Procdedurename",Param);
if (ds.Tables.count > 0 && ds.Tables[0].Rows.Count > 0)
{
dt = ds.Tables[0];
}
return dt;
}
so i sent a code for him
posting the same here
public DataTable functionname()
{
DataTable dt = new DataTable();
DataSet ds = new DataSet();
ds = sqlhelper.ExecuteDataSet(strconnectionstring,CommandType.StoredProcedure,"Procdedurename",Param);
if (ds.Tables.count > 0 && ds.Tables[0].Rows.Count > 0)
{
dt = ds.Tables[0];
}
return dt;
}
Wednesday, March 4, 2009
How to call a stored procedure using SQL Server and C#.NET?
I answered for a question at Topcoder.com : http://toostep.com/question/stored-procedure?extraAction=fv
Posting the same answer here :
you can use SQLHelper which is a standard helper file provided by microsoft
and which will be very much useful for using it in the Data logic layer of all ur .net applications.
code will be like this :
include this sqlhelper.cs : http://www.koders.com/csharp/fidD4121D6E4BCA2DAB656D770903FECBFF7427D242.aspx?s=mdef%3Ainsert
to your solution :
using Helper.SQLHelper;
SqlParameter[] Param = new SqlParameter[2];
Param[0] = new SqlParameter("@number", objBLL.nNo);
Param[1] = new SqlParameter("@name", objBLL.strname);
DataSet dsstudentdetails = new DataSet();
dsstudentdetails = SqlHelper.ExecuteDataset(strSQLConnectionString, CommandType.StoredProcedure, "Getstudentdetails", Param);
if (dsstudentdetails.Tables.Count > 0)
{
return dsstudentdetails;
}
else
{
return dsstudentdetails;
}
here objbll is the business logic layer object for which u can pass data from ur presentation layer and the total bll is passed to the function
Posting the same answer here :
you can use SQLHelper which is a standard helper file provided by microsoft
and which will be very much useful for using it in the Data logic layer of all ur .net applications.
code will be like this :
include this sqlhelper.cs : http://www.koders.com/csharp/fidD4121D6E4BCA2DAB656D770903FECBFF7427D242.aspx?s=mdef%3Ainsert
to your solution :
using Helper.SQLHelper;
SqlParameter[] Param = new SqlParameter[2];
Param[0] = new SqlParameter("@number", objBLL.nNo);
Param[1] = new SqlParameter("@name", objBLL.strname);
DataSet dsstudentdetails = new DataSet();
dsstudentdetails = SqlHelper.ExecuteDataset(strSQLConnectionString, CommandType.StoredProcedure, "Getstudentdetails", Param);
if (dsstudentdetails.Tables.Count > 0)
{
return dsstudentdetails;
}
else
{
return dsstudentdetails;
}
here objbll is the business logic layer object for which u can pass data from ur presentation layer and the total bll is passed to the function
Sunday, March 1, 2009
Shiva Manasula Shakthi
Saw the Film Shiva Manasula Shakthi,Tamil film at Sangam theatre
this evening
Both Jeeva and Anuya's acting are great.
Both of them are fighting together till the end for small small reasons.
And everything is like a true love story
and what happens in a real life like some small small fights between the boy and the girl even after marriage (The same like whats happening in my real life :) )
I liked it very much
and some dialogues like 'Ennapa nee ethukku eduthalum school payyan mathiri amma va kooda kooptutu vandhudare nu anuya voda father solradhu' Superb.
Dont know why times of India gave only 2.5 rating for this
I would give nearly 4.5 for it.
Such a nice story
this evening
Both Jeeva and Anuya's acting are great.
Both of them are fighting together till the end for small small reasons.
And everything is like a true love story
and what happens in a real life like some small small fights between the boy and the girl even after marriage (The same like whats happening in my real life :) )
I liked it very much
and some dialogues like 'Ennapa nee ethukku eduthalum school payyan mathiri amma va kooda kooptutu vandhudare nu anuya voda father solradhu' Superb.
Dont know why times of India gave only 2.5 rating for this
I would give nearly 4.5 for it.
Such a nice story
Thanks to Deepak
I would like to thank Deepak Kumar Vasudevan for encouraging me in writing blogs.
After a long time of his advice i have just started writing blogs.
Hope i will continue this with full enthusiasm and excitement
After a long time of his advice i have just started writing blogs.
Hope i will continue this with full enthusiasm and excitement
Subscribe to:
Posts (Atom)