You can then store this date in your database.
DateTime dateUTC = DateTime.Now.ToUniversalTime();
If you want to display it back to local time use:
DateTime dateLocal = dateUTC.ToLocalTime();
Reference: http://forums.asp.net/t/1217716.aspx
Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.
You can then store this date in your database.
DateTime dateUTC = DateTime.Now.ToUniversalTime();
DateTime dateLocal = dateUTC.ToLocalTime();
ConnectionString = System.Configuration.ConfigurationManager.AppSettings["MySetting"].ToString();
public string getConnectionString(string vConnectionString)
{
System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
System.Configuration.ConnectionStringSettings connString = null;
string connectionString = string.Empty;
if (0 < rootWebConfig.ConnectionStrings.ConnectionStrings.Count)
{
connString =
rootWebConfig.ConnectionStrings.ConnectionStrings[vConnectionString];
if (connString != null)
connectionString = connString.ConnectionString;
}
return connectionString;
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Session["listId"] = ddlList.SelectedValue;
GridViewStocksInLists.DataBind();
}
}
protected void ddlList_SelectedIndexChanged(object sender, EventArgs e)
{
Session["listId"] = ddlList.SelectedValue;
GridViewStocksInLists.DataBind();
}
Reference: This is from http://aspnet.4guysfromrolla.com/articles/110106-1.aspx
[Browsable (true)]
public string Value
{
get
{
MembershipUser currentUser;
currentUser = Membership.GetUser();
if (currentUser == null)
return string.Empty;
return currentUser.ProviderUserKey.ToString();
}
}
Server Error in '/stockmonger.com' Application.
Conversion failed when converting from a character string to uniqueidentifier.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting from a character string to uniqueidentifier.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.