c# - How can a date that's stored in a SQL Server Express database correctly sometimes display as 01 Jan 0001? -


this newspaper website run - it's quite busy (approx 2 million page views month) - don't know if traffic significant issue here or not.

but every few days seem entirely random collection of latest stories show dates monday, january 1, 0001 when formatted like:

this.newsstory.datepublished.tostring("dddd, mmmm d, yyyy") 

but looking @ data via sql server management tools, it's stored entirely correctly. , if refresh application pool website dates go being correct.

any ideas what's happening? more of iis problem sql or .net? lost this, when happens seems entirely random, , stories effects seems random.

it's windows 2003 server running iis 6. website coded in c# , data in sql server 2005 express database.

thank suggestions may have.

more code requested - here's .net code calling stored procedure:

public static datatable getnewsstorybyurl(string url) {    datatable table = newsstorydata.getdatatabletemplate();     sqlconnection con = new sqlconnection(configurationmanager.connectionstrings["fangleconnectionstring"].connectionstring);    sqlcommand cmd = new sqlcommand("getnewsstorybyurl", con);    cmd.commandtype = commandtype.storedprocedure;     cmd.parameters.add(new sqlparameter("@url", sqldbtype.nvarchar));    cmd.parameters[0].size = 512;    cmd.parameters[0].value = url;     try    {       con.open();       sqldatareader reader = cmd.executereader(commandbehavior.closeconnection);       table.load(reader);       reader.close();       con.close();    }    catch (exception ex)    {       if (con.state != connectionstate.closed)          con.close();        throw ex;    }     return table; } 

and here's stored procedure itself:

set ansi_nulls on set quoted_identifier on go  alter procedure [dbo].[getnewsstorybyurl] ( @url nvarchar(512) )   select             dbo.fangle_news.[identifier] identifier, dbo.fangle_news.[guid] guid, dbo.fangle_news.[url] url, dbo.fangle_news.pagetitle pagetitle, dbo.fangle_news.metakeywords metakeywords, dbo.fangle_news.metadescription metadescription, dbo.fangle_news.newsheader newsheader, dbo.fangle_news.newsabstract newsabstract, dbo.fangle_news.newscontent newscontent, dbo.fangle_news.imageurl imageurl, dbo.fangle_news.imagecaption imagecaption, dbo.fangle_news.image_w image_w, dbo.fangle_news.image_h image_h, dbo.fangle_news.datecreated datecreated, dbo.fangle_news.datepublished datepublished, dbo.fangle_news.datelastmodified datelastmodified, dbo.fangle_news.createdby createdby, dbo.fangle_news.authoredby authoredby, dbo.fangle_news.lastmodifiedby lastmodifiedby, dbo.fangle_news.[status] status, dbo.fangle_news.tags tags, dbo.fangle_news.priority priority, dbo.fangle_news.version version, dbo.fangle_news.sendtotwitter sendtotwitter, dbo.fangle_news.twittertext twittertext, dbo.fangle_news.picturepurchaseurl picturepurchaseurl             dbo.fangle_news (nolock)            dbo.fangle_news.[url] = @url     , dbo.fangle_news.[status] = 2     , dbo.fangle_news.version = 1 


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -