Friday, 20 January 2012
SQL Insert Statement Issues

Have you ever got the following SQL Insert statement issues

"There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement."

Like me you probably went and counted your columns and then counted your values and realised they were the same so spent ages scratching your head trying to figure out what on earth was going on. Well here is how I managed to reproduce the issue.

insert into myTable ([columnA], [columnB ) values (1,2)

Did you see what I did in the above statement? I left the "]" off the end of "columnB" the above statement will give you the above mentioned error message. It was pretty much a typo on my part and it took me ages to find it in a large SQL Insert statement.

Hope this helps anyone who has gone about trying to solve the above problem and found they do have equal columns and values.

posted on Friday, 20 January 2012 14:39:31 (GMT Standard Time, UTC+00:00)  #    Comments [0]

 Thursday, 29 December 2011
My WiFi IP Camera/Baby monitor

wifiCam

I remember being in a Microsoft building many years ago wondering what was the best time to go to the canteen when one of the guys I was working with told me to just check on the Intranet. He logged in and showed me a live web cam of the canteen area, placed there so the staff could see when the canteen wasn't busy to go down for lunch.

Suddenly I was more interested in the camera than in lunch as my colleague informed me it was an IP Camera.

"Where can I get one!" was my first question.

He told me they would probably retail at around £600. I gauped at him, I loved the idea of an IP Camera but I wasn't prepared to spend that much on one. Then roughly 6 years later. I discovered a Wireless Camera, with night vision, pan and title functionality, built in microphone and speakers for around £40! You have to admire the evolution of technology!

This camera is by no means the best in its class and from what I can see its a pretty cheaply manufactured Chinese device.  But for the money I spent on it, I get a lot more functionality than I had originally bargained for.

With a bit of fiddling I eventually got the camera to work on my home network on a static IP address. I then setup some port forwarding on my router so I could view the camera on the Internet (password protected).

The camera comes with its own built in web server which has interfaces for most browsers and mobile devices so you can move that camera around from your iPhone, Windows Mobile or Android phone if you want. The cool bit is, is if you install the iPhone or Android app you can also listen in over the camera's microphone! You can also speak over the camera's speakers using the app which is equally as cool when you're playing pranks on people.

At the moment I use the camera as a baby monitor. Its proved incredibly useful as one, given that I can check on the baby from any room in the house now and for the price it provides the same functionality for a much lower price than baby monitors with the same functionality.

posted on Thursday, 29 December 2011 14:54:08 (GMT Standard Time, UTC+00:00)  #    Comments [1]

 Saturday, 17 December 2011
Whirlpool ADP 451 Dishwasher constantly beeping

I wrote this blog article because I just couldn't find any information online about to resolve the above issue and hopefully it will save you some time.

Yesterday the drainage pipe on my washing machine came loose and the eventing water works filled the kitchen floor with water as I pulled the dishwasher out to hurriedly get to the washing machine pipe. After mopping up the floor and later that evening putting the dishwasher on, the dishwasher began to constantly beep/buzz and the Express wash light continually flashed. After some searching I eventually managed to get hold of the service manual (not the users manual) for the dishwasher.

It appeared this particular warning is error code 4 which indicates an "Overflow failure". The dishwasher beeps for 30 seconds and then constantly tries to drain water. The thing was there was no water in the dishwasher! However I did click that this may have had something to do with the washing machine flooding the kitchen earlier. Looking around the dishwasher I tilted it up on one side off the floor and as I did water poured out of a small hole onto the floor for a little while. I then tilted the other side of the dish washer over and more water leaked out over the floor for a little while. I then turned the dishwasher back on and hey presto it worked!

The dishwasher obviously thought it was filled with water. However the water couldn't be drained as it wasn't really inside the wash area.

Anyway hope this helps someone Smile

posted on Saturday, 17 December 2011 10:45:22 (GMT Standard Time, UTC+00:00)  #    Comments [3]

 Tuesday, 01 November 2011
Eating the Agile BDD Cake with SpecFlow - Part 2

In the previous part of this article I took you through how I would go through testing using Agile and BDD together in one process from the start to finish in a test project. In the previous article we had setup our project and our story/feature for viewing our basket and getting the tests to run and fail. Next we will code the basket to get the tests to pass.

So in my solution I have 3 projects.

image

I have my Domain, most of this is going to be encapsulated by my Model. The web is where I have my model, view and controller, and yes I probably would split the model out from the web project. Lastly we have the tests project where all of our features live.

On to the code.

So my test will be hooking into my Basket Model. My BasketModel consumes an IBasketRespository type for which I do not have an implementation of. The reason being, I am not doing an integration test so I don't really care what is in this object and will mock it using Rhino Mocks in my test.

   1:  using DemoBDD.Domain.Contracts;
   2:   
   3:  namespace DemoBDD.Web.Models
   4:  {
   5:      public class BasketModel
   6:      {
   7:          private readonly IBasketRespository _basketRespository;
   8:   
   9:          public BasketModel(IBasketRespository basketRespository)
  10:          {
  11:              _basketRespository = basketRespository;
  12:          }
  13:   
  14:          public BasketFormModel GetBasket(string basketId)
  15:          {
  16:              return Mappers.MapBasketDomainToBasketFormModel.MapBasket(_basketRespository.GetBasketByBasketId(basketId));
  17:          }
  18:      }
  19:   
  20:   
  21:  }

And now my test

   1:  namespace DemoBDD.Web.Tests.StepDefinitions
   2:  {
   3:      [Binding]
   4:      public class ViewBasketItemsSteps
   5:      {
   6:          private BasketModel _basketModel;
   7:          private IBasketRespository _mockbasketRespository;
   8:          private BasketFormModel _basket;
   9:          private string _basketId = "fakebasketid";
  10:   
  11:          [Given(@"that the shopping basket contains 0 items")]
  12:          public void GivenThatTheShoppingBasketContains0Items()
  13:          {
  14:              var mock = new MockRepository();
  15:             
  16:   
  17:              _mockbasketRespository= mock.StrictMultiMock<IBasketRespository>();
  18:   
  19:              Expect.Call(_mockbasketRespository.GetBasketByBasketId(_basketId)).Return(new Basket(){Items = new List<BasketItem>()});
  20:   
  21:              mock.ReplayAll();
  22:   
  23:              _basketModel = new BasketModel(_mockbasketRespository);
  24:          }
  25:   
  26:          [When(@"I view the basket")]
  27:          public void WhenIViewTheBasket()
  28:          {
  29:              _basket = _basketModel.GetBasket(_basketId);
  30:              Assert.IsNotNull(_basket);
  31:          }
  32:   
  33:          [Then(@"the basket will show an empty basket")]
  34:          public void ThenTheBasketWillShowAnEmptyBasket()
  35:          {
  36:              Assert.AreEqual(_basket.Items.Count,0);
  37:          }
  38:   
  39:   
  40:      }
  41:  }

And the results of my test.and it all worked first time.surprising Smile

image

.What next?

I think I like SpecFlow, I think I am liking it more than MSpec and I never thought I would find myself saying that.

But I find what I have done has still left me with many questions and I can start to think of all kinds of ways to refactor what I have done which is natural for any developer and tests or "specifications" help us make sure that what we are changing is still working once it has been changed.

So what would I change?

  1. I would probably move the tests to the controller and not the Model. Why? Because BDD is supposed to be a top down development approach. Work at the top and work your way down. Testing my controller is also going to test my Model for me in this case.
  2. If my project grew larger I may move the model into a separate project.

Unsure of

  1. Adding integration tests later on to cover the repository layer. Would these connect back to the same story/feature? Or would we have a different story or feature that covered this aspect?
  2. Bug fixing. Would we create features for bugs or would we update an existing feature to take the bug into account?
  3. Having been to a session on BDD I found it interesting how one team had thrown out tasks and completely replaced them with scenario's. In a way it makes sense and I would be intrigued to try this concept out for myself.
posted on Tuesday, 01 November 2011 09:41:45 (GMT Standard Time, UTC+00:00)  #    Comments [0]

 Monday, 10 October 2011
Eating the BDD and Agile Cake with SpecFlow - Part 1

Speaking to a colleague of mine one evening, we got talking about Agile and BDD. What I found interesting was that he was providing the Agile aspect for me and I was approaching it from the developers context. I realised that in many of the implementations of BDD I hadn't quite seen the connection happen from the user stories down to the actual BDD tests.  While I had seen BDD used I wasn't quite sure it was being done "properly" or working properly it seemed as though lip service was being paid to the methodology. He made the clever suggestion that maybe we should test it out.

"As in make an actual app for the purpose of testing the process?" I said, he nodded and I decided then I was hooked on the idea. I could probably blog about it and let people know about my experience using a test project and it would give me a chance to try out SpecFlow. I would expect to write roughly 3 blog articles covering the subject, feel free to comment on any aspect - all constructive criticism welcome Smile

So getting to the project. We agreed he would be the product owner and I would be the developer (naturally). He went away for a day and came back to me with the requirements for a basket application. He provided me with a user story and then some conditions of acceptance. I looked over his conditions of acceptance and made some more suggestions. We were essentially collaborating around the conditions of acceptance and wording them in the classic BDD syntax. This was good, this was what was supposed to have happened.

The app was to be a simple shopping basket you add products to. My initial reaction was to get coding the basket and I had to quickly stop myself as I realised I wasn't following the process. Do the tests first!

So my Project Setup was as follows. I won't dwindle too much around the SpecFlow setup as I am sure there are plenty of tutorials out there.

Install SpecFlow

Create an MVC project in Visual Studio 2010 and allow it to create an accompanying test project (we will use this later).

image

Change the app.config of the test project so SpecFlow will work with MSTest (and Resharper)

image

Step 1. Creating my feature using SpecFlow (in Gherkin). The features file type is available to you in Visual Studio after installing SpecFlow.

image

 

Step 2. Run my tests using Resharper and MSTest, as expected my tests fail and SpecFlow gives me recommendations on what it was expecting.

image

 

Step 3. Create a Step file for my actual tests (this is where the actual tests are coded in MSTest)

image

 

Step 4: I copy the suggested code from SpecFlow unit test in step 2 into my new Steps file

image

 

Step 5: I then rerun my tests and get a different error telling me that I basically have empty tests.

image

Step 6: I am now ready to start coding to fix my tests! Which I will cover in my next article.

posted on Monday, 10 October 2011 12:46:03 (GMT Standard Time, UTC+00:00)  #    Comments [0]

 Saturday, 01 October 2011
Solving the 3709 error problem

I've spent many weekends looking into this problem and thought I'd best blog it so some one else at least gets the benefit of it.

The issue I am talking about centres around the following error message.

"The connection cannot be used to perform this operation. It is either closed or invalid in this context."

The above error message has been a true bane to me. It was an issue on a classic ASP site that was quite happily ticking away for many years. I spent ages looking through the code ensuring that the SQL Connection was properly closed after each use and that ADODB.Recordsets were being used correctly. The error didn't make sense to me because the problem only happened occasionally and I was convinced it was either an issue with MDAC or the version of IIS (we had moved to a new server a few months ago) .

The solution
To cut a long story short, the solution I discovered  was in SQL Server 2005! Looking through the SQL server logs I discovered that after the last request SQL Server would "Auto Close" the connection and release resources. When the website made another request SQL would be busy spinning up which would then return the error above!

To stop this happening right click on your database in SQL Server Management Studio, select properties, then select Options and set "Auto Close" to false. I believe this option is now removed in newer versions of SQL Server.

 image

posted on Saturday, 01 October 2011 00:32:33 (GMT Standard Time, UTC+00:00)  #    Comments [0]

 Tuesday, 26 July 2011
SkyDrive, I wish it had a guarantee

I have always been a big fan of Microsoft's SkyDrive and the Windows Live Mesh Service that bolts onto it for syncing all of your folders in "the cloud". One of the things I like about SkyDrive is the ability to map it as a network drive on your machine with relatively little trouble at all. If I am out and about I can access my SkyDrive documents from any web browser I can also edit my office documents online using the Web version of Office. Although I must point out that the web versions of office do have a few limitations when it comes to editing documents with shapes and images I have discovered.

image

If I install the Live Mesh client on my computer I can also access my computer from a web browser anywhere in the world, Live Mesh will also sync my browser favourites and my Office Templates for me and it will do all of the above mentioned for free!

I believe that Microsoft are great at releasing brilliant services although I don't feel they get quite the cult following they deserve as a service that would have been released by Google or Apple. Microsoft's approach always appears to be an "on going thing", when Google, Facebook or Apple launch something new it usually ends up on some major news websites not just the usual technical news services.

One thing Microsoft could make a bit more clear are some tutorials on some of Sky Drives features . By this I am referring to the features I mentioned at the top of this article. I am surprised that few people realise you can map a drive on your machine to SkyDrive and there is no little app that offers to do this or tutorial on the SkyDrive site (that I could find) that brings this into view. While the more tech savvy users don't mind "hacking" about for this information the less technically astute would probably be lost. Mapping a drive makes things so much easier when uploading pictures and files to SkyDrive in bulk it also make working on Office documents a lot easier.

I believe Microsoft should charge for even greater amounts of space on SkyDrive which is something they don't currently do. SkyDrive is currently capped at 25gigs.  I as a user of the service feel that for such a great service, how on earth are Microsoft paying for it? What's the catch? It can't be cheap maintaining the software and infrastructure for such a service and I really can't see how advertising can cover the service. I feel that because its a free service Microsoft could pull it when ever they wanted to if they don't feel its adding value. While I doubt they would, I feel that paying for the service enters me into a contract with them and some type of a guarantee?

Microsoft appear to be very good at "changing" and reinventing everything every few years or changing how services work which can be difficult for users who get used to having things working in a set way. If I wanted to use SkyDrive as my primary storage options for "everything" I'd pretty much want some assurances that it will always be there and that I can access it the same way in the future i.e. a virtual drive on any machine I use in future. If you look at the service agreement on Microsoft's website the following from point number 5 regarding "Your content" has the following paragraph in bold.

"You're responsible for backing up the data that you store on the service. If your service is suspended or canceled, we may permanently delete your data from our servers. We have no obligation to return data to you after the service is suspended or canceled. If data is stored with an expiration date, we may also delete the data as of that date. Data that is deleted may be irretrievable."

The above paragraph is just about the only thing that stops me from using SkyDrive in a serious capacity and makes me feel that the service is seen more as a convenient virtual pen drive that you can access from anywhere or share parts of it with friends than an actual long term storage solution or backup. Its aim appears to just make your data available "everywhere" through syncing maybe with Live Mesh (only 5gigs though) with the machines you use, but at the end of the day you still need to invest in a good old fashioned hard backup solution for "your stuff".

posted on Tuesday, 26 July 2011 11:52:24 (GMT Standard Time, UTC+00:00)  #    Comments [0]

 Wednesday, 29 June 2011
My first experience with Google+/Google Plus

I received an invite to join the Google Plus Field Test from a friend of mine who works at Google. My first impressions of the sign up process for Google+ (or g+ as people now refer to it) was "this is rather simple" simple is good!

Page1

I suppose the beauty of Google+ is that most people have a Google Account, well lets put it this way most people in the IT industry have a Google Account and therefore a lot of the people I associate with have Google Accounts.

All Google+ asked me when I signed up was if I wanted to link my Google+ account to my PicasaWeb Albums, it automatically picked up that I had a Google Buzz account (which I seldom use). 

Logging into Google+ for the first time, you are presented with the following screen

 

GooglePlusHomePage

The first thing I noted about the interface in Google+ is its pretty clean, they've done a bit of work making sure its not cluttered. Facebook has that cluttered feel to it which has probably come about by Facebook bolting on new features throughout the years as its grown organically while Google has had the chance to think about this from the ground up.

The Circles
One of Google+'s selling points is its "Circles" concept, basically a human being has many circles, they can be a circle of friends, circle of associates a family circle.you get the picture.

GoogleCircle

Google+ suggests people I have corresponded with in the past be they from Google Talk, Buzz or my GMAIL contact list.

I can also import contacts from Yahoo and Hotmail.

I can then choose to add these people to my network by dragging them into the circle I think they fit into best.

Later when I want to share content I can choose which of these circles I'd like to share my content with or just make the content public. Google appears to have carefully noted peoples annoyances with Facebook and appear to be making sure Google+ does not fall into the same security trap Facebook did in the past. (hopefully I didn't speak too soon!)

 

The Streams
When posting updates, Google has a concept called "Streams", the circles you placed your friends into earlier each have their own corresponding stream where anything posted by these users appear in the corresponding stream.

writingupdates

As on a Facebook wall you can post different kinds of content into a stream such as photos, video's, your location and links.

Trying it out for a while I quite like the Stream concept I think its very cleverly done. I also like how easy it is to see who I am sharing my content/updates with by selecting a Circle from the drop down list (see the picture).


Hangouts
Another feature I didn't get to test out (not many of my friends are online early in the morning!) is a video conferencing feature called Hangouts. You can basically open a Hangout to which you can choose which friends or Circles of friends can join at their leisure. In a Hangout you can watch YouTube videos together and video chat or text chat to each other. The video conferencing with more than one person at a time seems to be a direct competitor with Skype's premium conferencing service. I can see the potential for Google to Launch a commercial version of this tool with their business offerings.

Security
So far Google have made the security simple to understand. You can access these settings from the top right hand side of the screen.

image

Google carefully explains to you what can and cannot be seen, how the various features work and how to change these settings if you wish.

You are also able to see how other people might see your profile by typing in their username.


Conclusion
I have only used Google+ briefly but from what I have seen I am pretty impressed and I would love it to succeed. I know there have been a lot of anti-Facebook groups lately who are unhappy with the security in Facebook, I believe they now have a suitable alternative to choose from (albeit no one finds a gaping security hole). Will people leave Facebook in droves to join Google+ ? I am not so sure they would I believe people may sign up for both because its pretty easy to do so. Which one they may end up using the most may depend on several factors such as ease of use and where their friends hang out the most. As Google is just about everyone's search engine of choice these days the integration with their flagship search engine will probably appear seamless and easy for users to switch between.

I can foresee further integrations between Google+ and search which will help Google monetise plus. For example a friend finds a jacket they like on Google Shopping and hits a button on Google Shopping which says share with my Circle. The friends in that circle then get to see a nicely displayed update in their stream so they can click on the product and see more details. Every click in theory would earn Google AdSense revenue.

What I have found in the past is that Google often focuses on launching a product or service that at the time doesn't really make much sense until later when you see the bigger picture. If Google gets this right they could crack a large revenue stream if they get it wrong it could be yet another Wave.

Note: Please don't ask me for a Google+ invite. People in the field trial have not been given the ability to issue invites as yet.

posted on Wednesday, 29 June 2011 19:17:55 (GMT Standard Time, UTC+00:00)  #    Comments [0]