Sunday, March 23, 2008

I spent a little too long on this rainy Sunday afternoon tripping over myself. I'm using the SqlDataSource and the FormView controls in a quick prototype. I clicked the "Use optimistic concurrency" field in the SqlDataSource configuration page so it would compare the original values before updating the database.

I was going along fine when I realized the updates didn't work, but the insert was OK. After several repeated attempts with zero rows updates, I fired up the SQL Profiler and saw my update query right there, plain as day. Why wasn't the update working?

sql-profiler

I even grabbed the SQL out of SQL Profiler and ran it through Query Analyzer - and then bam! I could see it on my screen. The milliseconds for the date time fields were all set to zero, and the actual values in the database were non-zero values. Who was loosing the milliseconds?

Finally, it hit me. I was losing the data.

I was trying to be real smart about setting the hidden "Created" and "Modified" DateTime fields during the updating event of the SqlDataSource control. I would do a similar assignment during the update event for just the "Modified" DateTime field.

protected void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
   DateTime now = DateTime.Now;

   e.Command.Parameters["@Created"].Value = now;
   e.Command.Parameters["@Modified"].Value = now;
}

As I was peering at this method, it struck me that I was inadvertently setting the fields to a value that was too granular for my SqlDataSource object. It wasn't passing back the millisecond value, so I compensated by making sure the value is always zero milliseconds, like so:

protected void SqlDataSource1_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
   DateTime now = DateTime.Now;
   now = now.AddMilliseconds(1000 - now.Millisecond);

   e.Command.Parameters["@Created"].Value = now;
   e.Command.Parameters["@Modified"].Value = now;
}

With this adjustment, my inserts and updates are playing nicely. Yay!

So, now that i works, I'm still not real happy with it. I'd much rather have the code check a single timestamp column named "Version" than see all that bloat in there.

Sunday, March 23, 2008 5:30:47 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, March 19, 2008

I've been trying to disable script using the IE Developer Toolbar for a while now. Well, at least I've wanted to for a while, but its was greyed out so I couldn't select it in the menu. Its a fine little menu, with "Disable" well placed between "Find" and "View", then when you click the Disable item from the menu, three options pop up: Script, Popup Blocker, and All CSS.

The All Css menu item worked fine, it would drop any styles applied to the page and show me the raw, unstyled HTML content. Yet for some reason the top two items were disabled.

I poured myself a fresh cup of coffee from the French Press sitting on my desk and thunk about it real hard. Then, I opened Internet Explorer, clicked Tools, Options and then navigated to the Advanced tab. Sure enough, the Disable Script Debugging options were selected.

internet-options

I cleared the checkbox and restarted IE. Low and behold, I could now disable the JavaScript because it was no longer greyed out in the IE developer toolbar.

ie-disable-script

Drat!

ie7
Wednesday, March 19, 2008 7:53:34 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, March 04, 2008

Not because we want to and not because its better, but because its in accordance with regulations written by the Federal Communications Commission. Right. Don't mention anything about that big cluster of wires that branch off into that secured room ran by people who don't work there. Stick to the 'better protect' copy.

comcast fcc security message

The image above is what I got when I logged into my Comcast cable account to find out how much last month's damage was. I'm not really digging the sites that say, ok, you've authenticated with a username and password, but it looks like you're on a different computer or different IP address, so I'm going to add one more thing you need to remember and type in. Isn't agility what the web is all about? I know there's a balance to strike, but we aren't there yet. Where's that damn CardSpace and OpenID?

Tuesday, March 04, 2008 10:14:21 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |