I had 17 (the number is not important except that it is more than one) Excel files I needed to get into a database and since wee happen to use SQL Server - I thought of SSIS. I was going to leave my trusty C# hammer in the tool bag for a more specialized tool. I was confident that even though I had not used SSIS for much (mostly trivial imports from SSMS) that I could get something running pretty quickly.
Well I could not have been more wrong.
I spent the entire day working through a series of SSIS issues specific to the problem I was trying to solve . The final issue was that a couple of the cells in Excel have more than 255 chars of data; what I nightmare trying to get the Excel driver to read more. And now that it is - its in an NTEXT data type which is practically useless when I really want a String. What a mess! Not to mention that I enlisted (wasted?) some help from other people (at least 4) who are much more knowledgeable on this technology than I.
The question I am asking myself is not whether to use a different tool (my trusty C# knife); but when I should have "cut bait and run"?
Every time I ran into an issue yesterday it felt like I was getting closer and closer to being done. Problem is that now feels like there was an infinate distance to travel; so closer being relative - i was never going to be done. At what point do I should I have realized this? Is one day too long to have been doing this? Is this just a case of arrogance and/or stuborness?
Just one of those things that makes me say Hmmmm.
It's hard to explain to people who don't do what I (we) do for a living this type of situation. I wonder how much time is spent / wasted doing just this sort of thing; using the wrong tool for the job. How many pople just keep banging a bent nail? Sure it works, but it's so britile you can never change it. I guess I could have just dropped a script component on the SSIS design surface and written the entire thing in C#. Too bad the debugger does not work. I am just too old to debug something using MessageBox.Show(). Geez! I am so anal about debuggers that a friend and I (he did most of the heavy lifting) wrote our own debugger for a Basic compiler we were using back in the early 90's!
I think I gave SSIS a fair chance. Now it's time to get this thing done.
Thursday, December 3, 2009
Tuesday, May 12, 2009
IIS 401.5 Error
Had a really weird problem today where I was getting a IIS 401.5 error on a subweb today. The problem shows up as a 401.2 error in the browser, but when you look at the IIS log it's reported as a 401.5.
I was running through all my usual ways of debugging these types of issues and non of the usual things worked. Asked a collegue for help because I must be missing something obvious. Then I was verbally walking him through the configuration and I mentioned that the problem was only happening on this subweb. Something clicked on both our faces - it's a subweb so there is more than one web.config in play here. I checked the web.config file and found that it was busted (the root site did not work either - but no one cares). I renamed the web.config file and bang, the site started working again.
Blogging this on the off chance it helps someone and to get it to stick in my own memory for next time.
I was running through all my usual ways of debugging these types of issues and non of the usual things worked. Asked a collegue for help because I must be missing something obvious. Then I was verbally walking him through the configuration and I mentioned that the problem was only happening on this subweb. Something clicked on both our faces - it's a subweb so there is more than one web.config in play here. I checked the web.config file and found that it was busted (the root site did not work either - but no one cares). I renamed the web.config file and bang, the site started working again.
Blogging this on the off chance it helps someone and to get it to stick in my own memory for next time.
Thursday, April 16, 2009
C# - Keep me from hurting myself
I just fixed a funny bug where it was behaving very odd and it was because I had a return statement where I intended to have a continue. I musta looked at that line a dozen times and did not think anything of it. Just went back to the basics of debugging and ran through the code line by line, iteration by iteration. What an embarassing relief!
[Upon further reflection]
What if there was new language feature that made this less likely to happen. Does it help readability and/or intent? Take the following loop.
foreach (var i in theCollection)
{
if (i.Visible == false)
continue;
// other code goes here
}
What if I could change the syntax to something like this...
foreach (var i in theCollection)
except i.Visible == false
{
// other code goes here
}
Upon futher thought what if I just used LINQ instead?
var iVisible = theCollection.FindAll( i => i.Visible)
foreach( var i in iVisible)
{
// other code goes here
}
Not to bad from a syntax point of view. I don't like that I am making a shallow copy of the original list for the purposes of only iterating through it. The language extension above works on the original list.
[Upon further reflection]
What if there was new language feature that made this less likely to happen. Does it help readability and/or intent? Take the following loop.
foreach (var i in theCollection)
{
if (i.Visible == false)
continue;
// other code goes here
}
What if I could change the syntax to something like this...
foreach (var i in theCollection)
except i.Visible == false
{
// other code goes here
}
Upon futher thought what if I just used LINQ instead?
var iVisible = theCollection.FindAll( i => i.Visible)
foreach( var i in iVisible)
{
// other code goes here
}
Not to bad from a syntax point of view. I don't like that I am making a shallow copy of the original list for the purposes of only iterating through it. The language extension above works on the original list.
Monday, April 6, 2009
Pattern for Extension Methods?
The more extension methods I see and write the more I am starting to see a loose pattern forming. If I write an extension method for IQueryable then why not write something similar for IEnumerable. Sure the implementation is different, but from the outside they both feel similar. Take for instance Distinct; why only have that on IQueryable? I ended up writing my own, which was not a big deal, but byt the time I finished all the tests and a quick peer review I had spent almost a 4 hours. Not to metion the email & SharePoint entry to everyone else in the org announcing a new release of the our extensions dll. Not bad, but just distracting. Here is the code for anyone that is interested. Sorry about the formatting, this editor is pretty lame for code.
///
/// Takes a List of type and a function as the key selector
/// and returns a unique list of .
///
///A class instance that uniquely identifies the current item. Strings work well.
///The type of items in the target and return lists.
/// The input list. Not changed by this method.
/// The function that returns a KEY that uniquely identifies the current item
///A list of where every item is unique by KEY
///
///
///
///
///
/// Worth noting that there is a distinct method on the IQueryable<T>, but this does not work
/// on List<T>. This is an entirely different implementation form that method.
///
///
/// The order of the original list is maintained, only duplicats are removed.
///
///
public static List Distinct(this List pList, Func pGetUniqueKeyFunc)
{
if (pGetUniqueKeyFunc == null)
throw new ArgumentNullException("pGetUniqueKeyFunc");
if (pList == null pList.Count == 0)
return new List(0);
var aDistinctKeyHash = new Hashtable(); // the list of unique keys - used for lookup
var aDistinctItemList = new List();
// go thru each item in the source list and get the key for that item from the delegate
// if the key does not exist in the hashtable then add it to the hashtable and the item return list
// rinse - repeat...
foreach (var aItem in pList)
{
var aKey = pGetUniqueKeyFunc.Invoke(aItem);
if (!aDistinctKeyHash.ContainsKey(aKey))
{
aDistinctKeyHash.Add(aKey, aItem);
aDistinctItemList.Add(aItem);
}
}
return aDistinctItemList;
}
///
/// Takes a List of type
/// and returns a unique list of
///
///
///
/// The input list. Not changed by this method.
/// The function that returns a KEY that uniquely identifies the current item
///
///
///
List<MyClass> aDistinctList = aTargetList.Distinct( i => i.Id);///
///
///
/// Worth noting that there is a distinct method on the IQueryable<T>, but this does not work
/// on List<T>. This is an entirely different implementation form that method.
///
///
/// The order of the original list is maintained, only duplicats are removed.
///
///
public static List
{
if (pGetUniqueKeyFunc == null)
throw new ArgumentNullException("pGetUniqueKeyFunc");
if (pList == null pList.Count == 0)
return new List
var aDistinctKeyHash = new Hashtable(); // the list of unique keys - used for lookup
var aDistinctItemList = new List
// go thru each item in the source list and get the key for that item from the delegate
// if the key does not exist in the hashtable then add it to the hashtable and the item return list
// rinse - repeat...
foreach (var aItem in pList)
{
var aKey = pGetUniqueKeyFunc.Invoke(aItem);
if (!aDistinctKeyHash.ContainsKey(aKey))
{
aDistinctKeyHash.Add(aKey, aItem);
aDistinctItemList.Add(aItem);
}
}
return aDistinctItemList;
}
eReading
Yes I have a couple of free minutes today. Just clearing some stuff out of my Inbox that has accumulated over the last 5 weeks of pounding out a cool POC.
A bunch of people here at work have bought a Kindle. A good friend uses his for both technical and personal reading. He was about to buy a v1 Kindle and opted to wait for v2. So far he is still on board. It gets me wondering if I would really use one or whether I just like the cool factor.
Honestly, I am not feeling like I would use it very much and it would be relegated to the long list of toys I end up giving away. Why? Because there are very few technical books I actually read cover to cover. I do much more browsing, skipping and flipping all of which just don't work in the e-mediums. I still like the feel of books. I like to highlight and write in the margins. I like to flip through a book I have not picked up in a while and find something new or something I marked up previously.
Take Safari. Every programmer here at work has a Safari membership. Nice. But I just don't use it that much for actually reading books. In fact when I talked to the Safari folks originally; their main use case is not for eReading but rather for finding answers to questions or topics.
My other use case for Safari is what I used to used Borders and Barnes & Noble for - to check a book out before I buy it. This is sweet. First to Safari, then to a discount book seller or Amazon to buy it used (love this).
A bunch of people here at work have bought a Kindle. A good friend uses his for both technical and personal reading. He was about to buy a v1 Kindle and opted to wait for v2. So far he is still on board. It gets me wondering if I would really use one or whether I just like the cool factor.
Honestly, I am not feeling like I would use it very much and it would be relegated to the long list of toys I end up giving away. Why? Because there are very few technical books I actually read cover to cover. I do much more browsing, skipping and flipping all of which just don't work in the e-mediums. I still like the feel of books. I like to highlight and write in the margins. I like to flip through a book I have not picked up in a while and find something new or something I marked up previously.
Take Safari. Every programmer here at work has a Safari membership. Nice. But I just don't use it that much for actually reading books. In fact when I talked to the Safari folks originally; their main use case is not for eReading but rather for finding answers to questions or topics.
My other use case for Safari is what I used to used Borders and Barnes & Noble for - to check a book out before I buy it. This is sweet. First to Safari, then to a discount book seller or Amazon to buy it used (love this).
What I am currently reading
...Pragmatic Thinking and Learning: Refactor Your Wetware
I am only 50% through. No code samples or object diagrams in this book. It's more about how to approach what I do as opposed to specifically how to do it. I like have been thinking more about this myself and am finding this book very interesting.
I liked the book by the same author (with others) called Pragmatic Programmer. Bernie turned me onto that book when it first came out and I recommend it highly. It's still as pertinent as the day it was written.
I am only 50% through. No code samples or object diagrams in this book. It's more about how to approach what I do as opposed to specifically how to do it. I like have been thinking more about this myself and am finding this book very interesting.
I liked the book by the same author (with others) called Pragmatic Programmer. Bernie turned me onto that book when it first came out and I recommend it highly. It's still as pertinent as the day it was written.
I finally bit the bullet and signed up for Twitter. I have no expectations of finding any value in this, but I wanted to at least say I gave it a try. It's also one of the few networking sites that is not currently blocked by our corporate firewall (LinkedIn is the other one). As a side note, eBay is not blocked either - sometimes I just don't understand the corporate mentality. Like we are buying our office supplies on eBay. Now that would be funny.
Subscribe to:
Posts (Atom)
-
I have been thinking about gaming a bit lately. In some part because of Twitch and it's association with Amazon and because someone on m...
-
“Vibe coding,” if we have to name it, is the instinct to follow an idea straight into a running system before the bureaucracy wakes up. It’s...
-
Turns out that once you leave Amazon, there is a lot to learn about the way the rest of the world builds systems. That was part of the reaso...