Posts

Expand your mind

The only hassle of working with Virtual Machines is being omniscient: how in the world am I supposed to know how big to make the virtual drive when I don't know what stuff I'm going to install on the machine? Solution: VMWare Converter This little beauty non only lets you convert physical machines to VMs, or Microsoft VMs to VMWare VMs, it also lets you convert VMWare VM's to another version and resize the disk along the way! sweet!

If I could get connected, I could tell who you are

Playing with Visual Studio 2008, .net 3.5 and SQL Linq today and decided to make the thing a real application. That means using a membership database. I really like using sql express for development (and deployment) of little applications. It's a shame that my hosting provider doesn't let you use an express database, but I digress... Anyway, how do you go about creating membership in an existing database... You twiddle with the command line parameters until you figure out that this is how: aspnet_regsql -A all -C "Data Source=.\SQLEXPRESS;Integrated Security=True;User Instance=True" -d "C:\MyProject\APP_DATA\aspnetdb.mdf"

You've been very helpful, can you just go away now.

Sometimes when dealing with a typed dataset (a good idea) you have a problem with constraints, or with nullable fields, or with other stuff. Microsoft gives you a less-than-helpful exception that says "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." Right... Well, if you use: ds.EnforceConstraints = false; then you can call this method which will output the table, row, column, and exact constraint that was violated. public void GetDataSetErrors(DataSet ds){ try { ds.EnforceConstraints = true; } catch(Exception ex) { foreach (DataTable table in ds.Tables) { foreach (DataRow row in table.GetErrors()){ System.Diagnostics.Trace.WriteLine("Table: "+ table.TableName); System.Diagnostics.Trace.WriteLine(ex.Message ); System.Diagnostics.Trace.WriteLine("Row: " +row.RowError); foreach (DataColumn col in row.GetColumnsInError()) { System.Diagnostics.Trace.WriteLine("Column " + col.Colum...

Does this dress make me look fat?

Here's a nice little bit of code that can be used to dynamically theme a website that has multiple domains at the same site. using System; using System.Collections.Generic; using System.Text; using System.Web; using System.Web.UI; namespace URLThemeHandler { public class ThemeHandler : IHttpModule { #region IHttpModule Members public void Dispose() { } public void Init(HttpApplication context) { context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute); } void context_PreRequestHandlerExecute(object sender, EventArgs e) { HttpContext currentContext = HttpContext.Current; if (!(currentContext.Handler is System.Web.UI.Page)) return; System.Web.UI.Page myPage = currentContext.Handler as System.Web.UI.Page; string strHost = currentContext.Request.Url.Host; if(ThemeExists(strHost)) myPage.Theme = strHost; } bool ThemeExists(string theme) { string strPath = HttpContext.Current.Server.MapPath("~/App_Themes/" + theme); return System.IO.Directory...

Can you hear me NOW?!?!

My wife is very disgusted with our packet8 telephone. Part of the issues we're facing are that our Belkin router will block the outbound voice (thinking that it is a DOS attack). In the security log, there was this entry: 07/17/2006 18:35:57 **UDP Flood to Host** 192.168.1.10, 8006->> 209.247.23.73, 62602 (from WAN Outbound) So, thanks to a technical article I found, there is a support page that references this URL: http://192.168.1.1/firewall_spi_h.stm which allows you to turn off the "SPI and Anti-DoS firewall protection:" It should be easier to turn off a feature like this than an undocumented feature.

It's about time...

Time and space. Two of my favorite things. Time keeps everything from happening all at once. Space keeps everything from happening to you. Time AND Space keep everything from happening all at once to you! The problem to be solved today is this: Create a .net object that has it's XML serialization saved to an XML column in a database table. Now, have a trigger (add/update) that takes that XML field and denormalizes its content to some additional columns. In this way, you have the denormalized data that you might want to use for joins and filtering without having to parse the XML field over and over. You'd create a class something like this: public class Foo { Guid _id = Guid.NewGuid(); //This is our object's database identifier DateTime _updated= DateTime.Now; //This was the last time the object was changed string _description = string.empty; public Guid Id{ get{return _id;} set{_id = value;} } public string Description { get{return _description;} set{_description = va...

U-Turn (Going the other way)

So, here's a way to get back a delimited list of items from a table. In other words, concatenate values into one column (that you can then take together to pass to my parse table function). --Setup a sample data to demonstrate the concept declare @Table1 as Table (id int, Item varchar(100)) insert into @Table1 values (1, 'a') insert into @Table1 values (1, 'b') insert into @Table1 values (2, 'c') -- show the table data select * from @Table1 --retrieve the data from @Table1 as a concatinated list Select distinct id, ( Select upper(Item)+' ' as [text()] from @Table1 S where id = T1.id for xml path('')) Items from @Table1 T1