An excellent article on the Asp.Net application and page life cyle. Please click here
Uncategorized
Initialising log4net logging for Asp.Net web app
Some snippet below:
protected void Application_Start(object sender, EventArgs e)
{
XmlConfigurator.Configure();
log4net.Repository.ILoggerRepository repo = LogManager.GetRepository();
foreach (log4net.Appender.IAppender appender in repo.GetAppenders())
{
if (appender.Name.CompareTo(“RollingFileAppender”) == 0 && appender is log4net.Appender.RollingFileAppender)
{
var appndr = appender as log4net.Appender.RollingFileAppender;
string logPath = “MyApplication.log”;
appndr.File = logPath;
appndr.ActivateOptions();
}
}
logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
var configSource = new XmlConfigurationSource(ActiveRecordConfigStream);
Assembly assy = typeof([ParentAssembly]).Assembly;
ActiveRecordStarter.Initialize(configSource, assy.GetTypes());
logger.Info(“My Application Starting…”);
}
Creating custom .NET Exceptions in C#
public class XyzlException : Exception
{
public XyzlException (string errorMessage, Exception inner) : base(errorMessage, inner)
{}
}
You can pass in a custom error message to your new Exception type.
Just try it out…
Using SQL Server CROSS APPLY to read XML segment
Here is an interesting code snippet:
declare @XML xml
set @XML =’
‘
select ExpressionAlias.student_name,
ExpressionAlias.subject_name,
ExpressionAlias.score
From @XML.nodes(‘./students/student’) Student (rowset)
Cross Apply
Student.rowset.nodes(‘./subjects/subject’) Subject (rowset)
Cross Apply (
Select Student.rowset.value(‘@name’,’NVARCHAR(20)’),
Subject.rowset.value(‘@name’,’NVARCHAR(20)’),
Subject.rowset.value(‘@score’,’INTEGER’)
) ExpressionAlias (student_name, subject_name,score)
Order By
ExpressionAlias.student_name ASC,
ExpressionAlias.score DESC;
Tech.Days.2010.United Kingdom
What the heck is SYLK File?
According to Microsoft:
A SYLK file is a text file that begins with “ID” or “ID_xxxx”, where xxxx is a text string. The first record of a SYLK file is the ID_Number record. When Excel identifies this text at the beginning of a text file, it interprets the file as a SYLK file. Excel tries to convert the file from the SYLK format, but cannot do so because there are no valid SYLK codes after the “ID” characters. Because Excel cannot convert the file, you receive the error message.
I got the error message:
‘SYLK: File format is not valid’
when trying to open a CSV file.
Apparently this is a known issue in Microsoft products.
Read more on KB323626
Geeks drive girls out of computer science
Interesting read on why ‘girls’ could be shying away from Computer Science!
|
The stereotype of computer scientists as geeks who memorize Star Trek lines and never leave the lab may be driving women away from the field, a new study suggests. |
Season greetings
Wishing you happy holidays! Merry Christmas and Happy and Prosperous New Year 2010.
"Cannot insert the value NULL into column ”, table ”; column does not allow nulls. INSERT fails."
One useful system stored procedure is sp_helpdb. This stored procedure returns information about all of your databases on your server such as the size, owner, when it was created and the database settings. One issue that you may run into is that the stored procedure does not provide data, but an error occurs instead. The error that you receive is “Cannot insert the value NULL into column ”, table ”; column does not allow nulls. INSERT fails.”
Useful tips to fix this here
Stackoverflow DevDays, London Oct 2009
Hurry hurry, limited places for this opportunity to meet with Stackoverflow members in this 1 day event.
More details on Joel’s site
See you there

