The Code Room

Microsoft have just released the pilot episode of “The Code Room”, an MSDN reality show in which real developers have to develop something given tight deadlines. Yes, it really is as boring as it sounds and goes to demonstrate why reality TV and software development haven’t been mixed previously.

The Code Room is probably the worst piece of propoganda i’ve ever seen. The presenters’ comment, something like “for those non-techies, ASP2.0 lets you make really great websites”, underpinning the ridiculous gimmicky nature of this presentation.

These developers appear to be simply code monkeys adopting the Microsoft click and drag mentality following a 1hr indoctrination session. No thought is given to proper application development and the resultant application would be usable only in an Intranet environment (although to be fair to the dev team, scaleability wasn’t a requirement).

Given Microsoft are trying to grow up with C#, Yukon, VS.NET2005 etc this kind of marketing gimmick does nothing but leave a bad taste in the mouth of any self-respecting developer.

Advertisements

Google auto-completion

Those people over at Google have just released a Beta version of their Google Suggest. This is just like normal Google, except that as you type it guesses what you’re trying to search for based on the most popular previous searches.

On a related note, over at WordCount.org you can see what the 88,000ish most popular words are in the world – interactively. And you can search for your favourite words. But whilst you’re searching, QueryCount is watching you and updating the list accordingly. Go search for something unusual and skew the results 🙂

I found a new HTML tag!

Well it’s not everyday it happens is it? There I was reading Jakob Neilsons’ article on Radiobuttons and checkboxes and I happened across the <label> HTML tag. Okay, so its only part of the HTML4 recommendation but it appears to work in Firefox and IE.

It basically lets you increase the target size of your radiobutton (which, as i’ve just read is called Fitts’s law) by making the text alongside the radiobutton linkable. This, i’ve achieved previously with a span tag. D’oh.

Sample form below. You’ll see that clicking on the “first name” takes you into the edit box for the first name, and clicking male/female chooses that radiobutton. Neat.

First name:
Last name:
email:
Male
Female

And here’s the HTML for that…

<p>
<label for="firstname">First name: </label> <input id="firstname" type="text">
<label for="lastname">Last name: </label> <input id="lastname" type="text">
<label for="email">email: </label> <input id="email" type="text">
<input name="sex" value="Male" id="male" type="radio"> <label for="male">Male</label>
<input name="sex" value="Female" id="female" type="radio"> <label for="female">Female</label>
</p>

Using OPENXML in SQL Server

Another example of using OPENXML to get data into SQL Server from ADO/ADO.NET. This one will fail when the Xml chunk you pass in is bigger than 8000 characters (ntext limitation). However you can pass an XmlDocument stream object to ADO and do that instead and avoid this limitation. MSXML3 or newer needed.

Here’s the Xml:

<cuesheet>
<summary>
<strandtitle><!–[CDATA[Strand title 0]]–></strandtitle>
<programmetitle><!–[CDATA[Programme title 0]]–></programmetitle>
<programmeid><!–[CDATA[0]]–></programmeid>
</summary>
<cuesheetitems>
<cuesheetitem>
<itemtitle><!–[CDATA[IT0]]–></itemtitle>
<composer><!–[CDATA[Composer0]]–></composer>
<musicpublisher><!–[CDATA[Publisher0]]–></musicpublisher>
<log>
<musiccode><!–[CDATA[AA]]–></musiccode>
<duration><!–[CDATA[11:00]]–></duration>
<timein><!–[CDATA[00:00:04]]–></timein>
<timeout><!–[CDATA[00:12:00]]–></timeout>
<visualcue><!–[CDATA[foo]]–></visualcue>
</log>
</cuesheetitem>
</cuesheetitems>
</cuesheet>

Here’s the Stored Procedure:

ALTER PROCEDURE sp_Insert_CueSheet_Openxml
@strXML NTEXT
AS
DECLARE @iDoc INT
EXECUTE SP_XML_PREPAREDOCUMENT @iDoc OUTPUT, @strXML
INSERT INTO CueSheet (StrandTitle, ProgrammeTitle, ProgrammeId)
(SELECT * FROM OPENXML(@iDoc, '/cueSheet/summary', 2)
WITH
(strandTitle VARCHAR(50),
programmeTitle VARCHAR(50),
programmeId VARCHAR(20))
)
DECLARE @cueSheetId INT
SET @cueSheetId = SCOPE_IDENTITY()
DECLARE cueSheetItem_cursor CURSOR FOR
(SELECT * FROM OPENXML(@iDoc, '/cueSheet/cueSheetItems/cueSheetItem', 2)
WITH
(itemTitle VARCHAR(50),
composer VARCHAR(50),
musicPublisher VARCHAR(50))
)
DECLARE @cueSheetItemId INT
DECLARE @xpath VARCHAR(100)
DECLARE @ItemTitle VARCHAR(50)
DECLARE @Composer VARCHAR(50)
DECLARE @Publisher VARCHAR(50)
OPEN cueSheetItem_cursor
FETCH NEXT FROM cueSheetItem_cursor
INTO @ItemTitle, @Composer, @Publisher
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO CueSheetItem (CueSheetID, ItemTitle, Composer, Publisher)
VALUES (@cueSheetId, @ItemTitle, @Composer, @Publisher)
SET @cueSheetItemId = SCOPE_IDENTITY()
SELECT @xpath = '/cueSheet/cueSheetItems/cueSheetItem/itemTitle[text()=''' + @ItemTitle + ''']/../log'
INSERT INTO CueSheetItemLog (CueSheetItemId, MusicCode, Duration, TimeIn, TimeOut, VisualClue)
(SELECT @cueSheetItemId, * FROM OPENXML(@iDoc, @xpath, 2)
WITH
(musicCode CHAR(10),
duration CHAR(10),
timeIn CHAR(10),
timeOut CHAR(10),
visualCue CHAR(10))
)
FETCH NEXT FROM cueSheetItem_cursor
INTO @ItemTitle, @Composer, @Publisher
END
CLOSE cueSheetItem_cursor
DEALLOCATE cueSheetItem_cursor
EXECUTE SP_XML_REMOVEDOCUMENT @iDoc

Here’s the C#

XmlTextReader reader = new XmlTextReader(@"c:tempdummy2.xml");
SqlConnection cnn = new SqlConnection("server=localhost;database=test;trusted_connection=yes");
reader.ReadStartElement("catalog");
cnn.Open();
while (reader.LocalName == "cueSheet")
{
string cueSheetXml = reader.ReadOuterXml();
// Pass the Xml to the database
SqlCommand cmd = new SqlCommand("sp_Insert_CueSheet_Openxml", cnn);
cmd.Parameters.Add("@strXML", SqlDbType.NText);
cmd.Parameters["@strXML"].Value = cueSheetXml;
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
cmd.Dispose();
}
cnn.Close();
cnn.Dispose();
try
{
reader.ReadEndElement();
reader.Close();
}
catch (XmlException)
{
}