25. October 2011 05:05by JP Hellemons in
C# I recently stumbled upon a small bug which had to do with a part of C# code that cleans up an HTML string which came from a database. This string is used as output on the web and therefore needs to be w3c and tidy!
I always used Tidy.Net for it. Really liked it and decided to check for a new version of that library while I was doing some code maintenance. That library's latest release date is from June 2005! that’s over 6 years old!
So I decided to go and look for a better solution. I found the TidyManaged project from June 2010. I wasn’t directly motivated to migrate to this library so my next step was a showdown between the two. More...
3. October 2011 05:44by JP Hellemons in
C# Today I had a DataTable object with the top x rows of a query.
select top 23 * from products
So my Asp.Net C# code looked like this:
private void SampleMethod(int toShow)
{
string sql = "SELECT top " + toShow + " * from products";
SqlCommand com = new SqlCommand(sql);
DataTable dt = dal.GetDataTable(com);
if (dt.Rows.Count > 0)
{
var a = dt.AsEnumerable().Where(
p => p.Field<int>("stock") > p.Field<int>("ProductMinStock"))
DataList2.DataSource = a;
DataList2.DataBind();
}
}This crashed as you might have noticed. The error was:
More...