Tuesday, 8 February 2011

Cannot change table design in SQL Management Studio 2008?!

Theres a stupid change to SQL Management Studio in 2008. When you go into design view in a table and make a change to a table structure that requires the table to be recreated (such as changing Allow Nulls, or making a column an Identity), the damn thing won't allow you to save the changes. Instead you'll get an irritating message allowing you only a Cancel option - so you lose your changes and are stuck.

After a lot of RDC to the server to use its 2005 Management Studio, I found this solution:

Go to: Tools > Options > Designers > Tables and Designers

and uncheck the Prevent Saving Changes that require table re-creation option

This will give you "normal" functionality whereby you can amend a table all you like.

Wednesday, 19 January 2011

Crystal Reports in Visual Studio 2010 Parameters Problem

I am banging my head off a brick wall.

I am working with Visual Studio 2010, creating a Crystal Report which is based on a stored procedure with 2 parameters. The report has 1 subreport with 3 parameters, 2 of which are the same as the main report (linked) and the other is based upon a field in the main report’s stored procedure (also used a subreport link here).

I can view the report in the preview window and it all works perfectly, prompting only for the main report’s 2 parameters.

In C#, I can get no further than “{missing parameter values}” when I try to run the report, Google yields lots of search results on this problem but the solutions don’t work and were generally posted in 2004ish for CR as a standalone product rather than something in Visual Studio.

I contacted SAP, they said it’s Microsoft I need to ask (buck nicely passed). I’m completely stuck and frustrated, if anyone knows the answer please tell me!

Any help much appreciated


Current Code:

ParameterDiscreteValue ThisParameterValue = new ParameterDiscreteValue();
            ThisParameterValue.Value = ClientRef;

UPDATE: You cannot use Crystal for VS2010 if you have VS2008 installed, they conflict with eachother. VS2010 Crysatral wont run aganst SQL2000 so I had no choice but to uninstall Crystal 2010, create the report in a 2008 class library, and then reference the library from my 2010 project.

This worked a treat.

Thursday, 17 December 2009

British Airways Cabin Crew SQL Timeout Exception

Right, before getting to my actual solution to the British Airways SQL Timout Exception, I'll explain where I came accross the problem in the first place.

Its called the news. BA cabin crew are planning to strike over Christmas, I am seriously pissed off with them, not because they want to strike but because of their reasons.

They say: "we are understaffed and we arent paid enough"

All I hear is: "I only get paid at least £20,000 a year to be a barman on a plane serving food and drink with a once-a-day task of waving my arms around while nobody pays attention. In my free time I'm generally somewhere hot, staying in a hotel that the airline pays for, getting lashed on duty free alcohol, smoking duty free fags and shagging my work colleagues. It's not on, I only get to go abroad 40 times a year and in my career I have only seen 100 different countries. Im off on strike, I dont care that I'm ruining the christmas of countless children, some of whom were going to lapland to see santa but now cant and will probably be scarred for life. I also dont care that by striking I am putting millions of customers off flying with BA and from the revenue loss there may be redundancies in which case my job will be gone and this strike will be pointless anyway."

So, the problem here is that this statement times out due to the high number of records returned:

SELECT * FROM BA_CabinCrew WHERE IsBastard = 1

So to get around the problem I found the best soluton to be:

DELETE FROM BA_CabinCrew WHERE IsBastard = 1

In English, sack the lot of them. There's 2.1 million people out of work in this country, run a mass recruitment drive, it won't take long to replace them all and theres 8 days until Christmas so you could probably have them all trained up by then aswell.

Rant Over. My next post will be purely C# or T-SQL, promise :)

Dedicated to BA Victims Lee-Man and Ann

Thursday, 10 December 2009

SQLDataReader and Output Parameters

I have a WPF ListView bound to a Generic List of my custom business objects, I decided to implement a backgroundworker to populate the collection and report progress to a ProgressBar control.

So, I need a record count and, for performance, a SqlDataReader. My thought was to return both results from a stored procedure and the nicest way to do that is with an OUTPUT parameter.

The goal is to return the record count from the output parameter to my progress bar BEFORE reading the SqlDataReader so thet I can set ProgressBar.Maximym, then do a while loop to populate the collection incrementing ProgressBar.Value on each iteration.

Can I do this? NO.

I had it all coded, ran it, and got a result of null in the parameter, no matter what I tried it refused to give me a value. I researched for a couple of hours to no avail - then I found a small note on a web site that with a SqlDataReader, you must complete a full read of the reader before the output parameter becomes available.

Well, I'm screwed, I can revert to using a DataTable and yes it wont make a massive performance difference but for the population of the collection a SqlDataReader is definitely the best option and I am denied it.

Column Header Sorting In WPF - Damn You Intellisense!

Ever since I started using WPF I have been annoyed by the lack of sorting support from its column headers, it didnt even seem to offer a click handler for the headers of any kind!

Having wandered around Google I found some forums where users were talking about the problem, with one MS post saying "sorry its not supported, we will endeavour to add it in the next version" while referencing version 1.

I stumbled upon one post which said that "GridViewColumnHeader.Click" would do the trick, but when I tried to use it there was no sign in intellisense. I use Visual Studio 2008 so I thought that maybe it was something from a 2005 service pack.

At the time I moved on to something else but I had the same problem this week so I started researching again. I found nothing at first, but then I stumbled upon a forum where a user said "its not in intellisense, but if you type it in and hit '=' it will generate the correct event handler as usual and it will work perfectly"

Voila, problem solved

Monday, 20 July 2009

ASP.NET Rich Text Box Control

I had trouble the other day finding a good rich text box for ASP.NET that was free , and had built-in script prevention. Below is the solution, it doesnt have a spell checker but its a very good free control that is very easy to add to your solution