Tuesday, December 27, 2011

SQL to ORDER BY datetime Field by date

It's tricky to order by a datetime field by date because the GROUP BY clause attempts to group by seconds instead of days. My solution is:

SELECT
distinct Convert(varchar(10),Tasks.DateCreated,101) As Date,
Count(Convert(varchar(10),Tasks.DateCreated,101)) As DateCount
FROM Tasks
GROUP BY Convert(varchar(10),Tasks.DateCreated,101)

Wednesday, June 22, 2011

Output a DataTable in Random Order - VB.NET

To change the order of a DataTable to random, you need to change the DataTable to a DataView, add a column to the DataView, populate the fields of that column with random numbers, sort the DataView by that column, and then change the DataView back into a DataTable. The good news is this can be done in just a couple lines of code.


Dim myDataTable As DataTable
myDataTable = Whatever your data table is
myDataTable.Columns.Add(New DataColumn("RandNum", GetType(Integer)))
Dim i as Integer
Dim rndNum as New Random()
For i = 0 to myDataTable.Rows.Count - 1
myDataTable.Rows(i)("RandNum") = rndNum.Next(10000)
Next i
Dim myDataView as DataView = myDataTable.DefaultView
myDataView.Sort = "RandNum"
myDataTable = myDataView.ToTable()

Monday, March 14, 2011

Microsoft Expression Locks Up When Saving Page

If Microsoft Expression locks up, freezes, or crashes when you are trying to save an .aspx .master or other type of page, you are not alone.

Fix:
In Expression, Click --> Tools --> Application Options --> Configure Editors.
For each file extension, click New Editor --> Open as XML. Move the XML editor to the top so it says (default).

Hope this helps

Monday, January 17, 2011

Outputting Tableless HTML Navigation with ASP>NET

If you are reading this, you are probably desperately trying to find a way to implement site navigation in an unordered list. You've probably also wasted several hours on the internet learning the basics of the DataList and DataTable controls built into ASP.NET; only to learn those two controls are contrived in such a way as to only output html in a table based format.

The solution is to use an asp:repeater. Here is a really well written article describing what I agree is the best method for outputting site navigation in an ordered list format.
  1. Output your data to an xml sitemap
  2. Display the sitemap on the page as an unordered list using a Repeater .



Sunday, August 22, 2010

New Stylesheet for PORDL

So, I spent the whole day Sunday making a new Generic XSL stylesheet for PORDL. I built javascript into the XSL that ticks through the nodes showing only one at a time. I was pleasantly surprised that they worked great out of the box for Picasa and FlickR gallery feeds.



PORDL makes it easy to embed the gallery with just one line of code:



<script type='text/javascript' src='http://pordl.com/js.aspx?id=289' ></script>

Friday, August 13, 2010

What's the Deal Windows?

For many, many years now, I have been seeing this stupid window, "Please wait while Windows checks for a solution", every time programs crash on my machines. This stupid popup window thing has never, ever worked. It is a total waste of time. I pretty much hit "Cancel", now, whenever I see it. Come on, Microsoft, are you every going to get this thing working?

Wednesday, July 21, 2010

Pass Querystring Parameter to ASP.NET Control

Although this is grade school stuff, when you can't get something working, you need to consult Google for the answer. But, I couldn't find the answer on Google. So, I will be the first, I guess:



I was doing some cross-browser scripting, trying to get the output of a ASP.NET contol to appear on a PHP page on another site. But, your reasons will probably be different. In any manner, if you need to pass variables through the querystring to an ASP.NET page, this info may help:




<asp:myControlName myPropertyName="'<%# Request.QueryString("myURLvariableName")%>' ></asp:mycontrolname>