Archive

Archive for January, 2010

State of the Bicycle – January 25, 2010

January 25th, 2010 joelhainley No comments

A lot of rain came in this last week. So for most of the week I spent time riding on the indoor trainer, listening to books on tape. Good workouts for sure, but nothing beats getting out and putting some pavement under your wheels. On Saturday I got out for a ride with Colin and ended up with 75 miles for the day. Colin introduced me to the beauty of espresso and I don’t think I’ll ever be the same. Good Stuff!

starting weight : 229.5
ending weight : 225
total mileage for the week : 75.7
total ride time for the week : 06:29:05
total calories burned this week on the bicycle : 7987

Hopefully the weather will cooperate a little more this week and I can get out and put some miles on, if not, I’m right in the middle of Spook Country by William Gibson and it’s starting to get good! Well that’s it for the week, go ride your bike.

Categories: bicycle Tags:

SQL Server Notes #3 – Except and Intersect

January 24th, 2010 joelhainley No comments

I’m sure you’ve all heard about the Union operator, it joins result sets together into a single record set. I haven’t used UNION very often but it’s definitely one of those operations that you are happy for when you need it. The thought of having to write a bunch of temporary table, select/insert queries to get the same data is not an appealing one.

Along with UNION there are two other similar operations that perform logic upon those result sets instead of just pushing them together and returning them. These operations are EXCEPT and INTERSECT. Some of you will probably be laughing at me when I tell you that I wasn’t aware of the EXCEPT and INTERSECT operators. Well you don’t have to laugh any more because now I know! Simply put these operators do much the same thing as UNION except that they perform comparisons between the results of two queries and produce a result set based on the existence of the records in both tables. Good stuff.

ASP.NET AJAX AutoCompleteExtender not working

January 19th, 2010 joelhainley 2 comments

I was working on some new features for a client recently and they had a need for an AutoCompleteExtender on one of their forms. I hadn’t used the AutoCompleteExtender yet so I read through the documentation, coded up a webservice, and added  the appropriate items to the page and ran the app. When I tried typing into the TextBox that the AutoCompleteExtender was pointed at, nothing happened. In this posting I will detail the things that I looked at, and try to put together an accurate guide to making sure you’re AutoComplete works. I tried some of the “tips” that are out there after I had things working and they don’t help. So hopefully this will be a bit more definitive and useful than what I came across.

The first thing that I looked at was the method signature of the webservice. The documentation indicates that you need to use one of the following method signatures :

public string[] GetCompletionList(string prefixText, int count) { … }

..OR..

public string[] GetCompletionList( string prefixText, int count, string contextKey) { … }

What the documentation doesn’t tell you is that the name/spelling/capitalization of the method signature must match EXACTLY. If you decide that you don’t like the camelcase on the prefixText and want to use prefixtext instead….IT WON’T WORK. So make sure you have those signature matching correctly. I have seen some indications on the internet that you should use a static method such as :

public static string[] GetCompletionList(string prefixText, int count) { … } // !!! DON”T DO THIS !!!

DON’T DO THIS. It doesn’t work. Only the exact methods defined in the documentation and shown above will work.

Back to my project, I get these methods defined properly, compile the project, go to my textbox start to type and still I get NOTHING. So I look over the documentation and see some information about the class/method attributes that must be added. The documentation shows the following :

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompletionList(
string prefixText, int count) { … }

What they don’t show in the documentation is that you need to also add the following to the class definition

[System.Web.Script.Services.ScriptService]

So I make these changes and run the application again, and STILL it doesn’t work. I’m stumped. I put a break at the webservice method and run again and it’s not even hitting the webservice. After a little bit of digging I come across Adding ASP.NET AJAX Configuration Elements to an Existing Web Site and a lightbulb goes on. This project was not setup as an AJAX.NET site, in fact it predates ASP.NET AJAX by a couple of years. Sure enough as I start to dig through the documentation I notice mappings to handlers for the webservice calls. So I follow the changes specified and run the site and it worked!

It took me a while to get this figured out, and I suspect there might be a few others out there that might have some problems getting this working. Below is a complete class that you can use as a reference. I haven’t included any of the code defining the AutoCompleteExtender because the documentation seems sufficient and I didn’t have any problems. There is also a video on the ASP.NET AJAX site that walks you through configuring your first AutoCompleteExtender and does a good job, as long as your site is configured properly!

Good luck!

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using DALInterface;
using CGWeb.framework;

namespace CGWeb.webservices {
///


/// Summary description for NewDXCompletion
///

///

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class NewDXCompletion : System.Web.Services.WebService {

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompletionList(string prefixText, int count) { … }
}
}

State of the Bicycle – January 18, 2010

January 18th, 2010 joelhainley No comments

The week went pretty well. I was able to get out and ride all week long, Sunday we started getting some rain and I was still a bit tired from Saturday’s ride so since I was ahead of my scheduled miles for the week I decided to just take another day off.

starting weight : 234.5

ending weight : 229.5

total mileage for the week : 138.6

total ride time for the week : 9:29:17

total calories burned this week while bicycling : 9273

I’ve started doing a bit of weight lifting and some core work in addition to my bicycling and boxing. With any luck this will help when the mileage starts to get longer. That’s all for the week, go ride your bike.

Categories: bicycle Tags:

SQL Server Notes #2 – How To Ensure SQL Server Will Ignore Your Indexes

January 14th, 2010 joelhainley No comments

Hopefully that title got your attention. When I started reading about some of the things that can cause the query optimizer to ignore your indexes it really caught my attention. Below are a few seemingly innocuous things that you can do in your sql statements to force the query optimizer to happily ignore your indexes.

  • Use a NOT operator in your WHERE clause – That’s right, if you don’t want to use indexes just drop a NOT operator in your WHERE clause
  • When Using An OR operator, reference columns that are not indexed – If you specify columns in an OR operator that are not indexed, all indexes that are associated with columns in the or clause will be ignored.
  • Put a leading wildcard character in your WHERE clause – If you do something along the lines of “select NAME from school_records WHERE name is like %XX%”, the index that you put in to speed up searches of the names will do absolutely no good.

There will probably be MANY more things that I will discover as time goes along related to nuances of indexes but I thought these were interesting because they seem really harmless. I think it’s useful to know that how you go about logically selecting data can impact query performance in potentially drastic ways