Archive for July, 2008

Visual Studio Database Projects with SQL Server 2008 or ‘Why do I prefer Google Search?’

Ok, I’m going to mix some info with a little bit of remarks on search engines.
First up, if you encounter an error when creating a Visual Studio Database Project with SQL Server 2008 telling you only version up to 2005 are supported, just download the
Microsoft® Visual Studio Team System 2008 Database Edition GDR July CTP

I encountered the error on a server where there was a standard Internet Explorer installation which of course point to Live Search, and I don’t really mind it usually, because hey it’s a server, I don’t want to personalize anything there. So I started typing in the search field ‘visual studio database project sql server 2008′ and hit enter.

Up came the live search result. Next I tried Google. Then just for sake of comparison I tried Yahoo.

I ask you honestly, which result set do you prefer? Why is Google the only who returns the result that I need and therefore want at the top, Yahoo gave it to me on the bottom of the first page which is not perfect but ok, but Live Search starts its results with BizTalk entries and none of the entries on the first page get me anything helpful? I’m not the only one who hardly ever clicks on page 2, so whatever is on the first page needs to be important. To be fair this is not a test of anything, just a single search, but it does get you thinking. I specifically choose Google, even though I’m otherwise flooded by and enjoy Microsoft technologies, and I don’t think that will change anytime soon.

Outlook Form Regions / User Properties / Add-Ins / Ribbons – A quick walkthrough

Code for this sample available here. Sorry it’s on GigaSize, but in.solit.us is down, and SkyDrive registration gives me an error code 15.

A couple of days ago I was asked at work about some troubles a team was having with user properties begin written by a form region control and not being able to be read from an add-in. I couldn’t figure out what the problem could be, so I decided to put together a small example that does just that. So here goes another one of those 5-minute quick introduction how-to’s.

I remember back about 5 years ago when I first wrote an Outlook plugin using IDTExtensibility and COM interop and hated it. I got the job done, but it wasn’t a pleasent experience. Look ahead a couple of years and the basic technology for connecting with Office applications has stayed the same. It’s still COM interop on the bottom layer, but we have an advantage. Microsoft has abstracted those dirty layers to some extent (there are lot’s of areas where the ‘old’ stuff still pop ups).

Anyhow creating Outlook plugins (or any Office plugins for that matter) has become very easy in Visual Studio 2008. Simply fire up a new solution, add a Office extensibility (for example Outlook 2007 Add-in) and you are ready to go. In my case I want to add a user property called ‘birthday present’ to my contacts with a form region and everytime Outlook starts I want it to check if there are contacts who have a birthday next week and check if that user property is set (otherwise warn the user, that he needs to get a birthday present). Stupid but simple enough to show this stuff.

First off we need a form region. Add a new item and add ‘Outlook Form Region’. Give it a name, choose an object type for it to appear in and choose a location for it. I chose ‘Adjoining’ an ‘Contact’ to put it on the bottom of the contact form. Design your form region using your Windows Forms skills. Switch to Code view. The FormRegion class is very generic, you have access to a this.OutlookItem which is of type object. Since we know we are working in a contact context, go ahead and create a property to hide the casting:

private ContactItem ContactItem
{
	get
	{
		if (!(this.OutlookItem is ContactItem))
			throw new System.Exception("Not running inside a contact form.");

		return this.OutlookItem as ContactItem;
	}
}

While we are at hiding some of the dirty stuff and since we will be dealing with a user property from some places in the code let’s go ahead and create a static helper class that returns us a UserProperty that we can work with.

namespace Sample.OutlookFormRegions
{
    internal static class UserPropertyHelper
    {
        // the id of the field we are working with
        private const string UP_BIRTHDAYPRESENT = "up.sample.birthdaypresent";

        public static UserProperty GetBirthdayPresentUserProperty(ContactItem contactItem)
        {
            if (contactItem.LastName == "TEST") /* don't want to clog */
            {
                UserProperty _userProperty = contactItem.UserProperties
                    .Find(UP_BIRTHDAYPRESENT, true /* search custom fields */);

                if (_userProperty == null)
                {
                    // Add the UP because it does not exist
                    contactItem.UserProperties.Add(
                        UP_BIRTHDAYPRESENT,             // Name
                        OlUserPropertyType.olText,      // Type
                        false,                          // Add it to the folder
                        0);                             // Display Format

                    _userProperty = contactItem.UserProperties
                        .Find(UP_BIRTHDAYPRESENT, 
                        true /* search custom fields */);
                    contactItem.Save();
                }

                return _userProperty;
            }
            else
            {
                return null;
            }
        }
    }
}

It’s fairly simple. First we use Find to look for the user property. If it does not exist it returns null, so we go ahead and create it. The Add method takes four parameters. The name, the type (OlUserPropertyType), a bool if we want to add it to the folder properties (if we choose yes, we could use and show it in the contacts list view) and a last value regarding the display format. This is dependant on the type. For the text type there is only one display format, therefore 0.

Back to our form region we have two events that we use to load and save the custom data.

private void MyFormRegion_FormRegionShowing(object sender, System.EventArgs e)
private void MyFormRegion_FormRegionClosed(object sender, System.EventArgs e)

In both we use our helper class to get the user property. Don’t forget to call the Save method on the contact to save the data. It is not enough just to set the value of the user property.

UserPropertyHelper.GetBirthdayPresentUserProperty(this.ContactItem);

Now we need our code to check for upcoming birthdays and missing presents.

public void CheckBirthdayPresents()
{
	m_nsMapi = this.Application.GetNamespace(MAPI);
	m_folderContacts = m_nsMapi.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);

	for (int _contactIdx = 1; /* COM Interop => 1-based */
		_contactIdx <= m_folderContacts.Items.Count;
		_contactIdx++)
	{
		var _contact = m_folderContacts.Items[_contactIdx] as ContactItem;
		if (_contact!=null)
		{
			UserProperty _userProperty = UserPropertyHelper.GetBirthdayPresentUserProperty(_contact);

			[...] Do the nifty checking here...
		}
	}                                      
}

First we need to get a namespace, which is basically a session to work in. You can go ahead and use the this.Application.Session object to get the current local MAPI session. Out of bad habit I used the old method via GetNamespace(“MAPI”). It doesn’t buy you anything to do it my way, you can only ever pass “MAPI” into that method and will only ever get the local mapi session. But you know, bad habits are hard to get rid of (for example my funny underscore thing – but that’s a story for a different post). Back to the code.

On that session we can ask for the contacts folder using the GetDefaultFolder and passing in the type for Contacts. We can run through those contacts, but remember this is COM and the collections there are not 0-based but 1-based. So start counting at 1 and finish your loop on smaller OR EQUAL than the length of the array. (I forget that one every time!)

Now we want to add a ribbon to give the user a the possibility of manually starting the check procedure which is done when Outlook starts automatically. Doing this in a ribbon is of course the worst possible place to do this, because the ribbon in Outlook only appears when you open items (e.g. answer an email message, open a calendar item). Ideally you would put the button in a standard old-style menu in the main application, but then I couldn’t show you how to quickly add a ribbon to your app. We will just make the user open a contact and press the button.

Add a new item ‘Ribbon (Visual Designer)’ to your project. First thing you want to do is specify when it appears. Open the ribbon in designer mode, then use the Properties window and navigate to the Ribbon object in the top drop-down.

There you change the RibbonType property to ‘Microsoft.Outlook.Contact’. Now it will appear as a seperate group in the ‘Add-Ins’ tab in the Contact inspector. You can simply drag a button from the toolbox to the designer (remember to use the Office Ribbon Controls). In the click event of the button you call the method we created above. To do that I decided to pass a reference to the add-in to my ribbon and call the public method.

Voila that was simple wasn’t it. As always hope it helps!

PS: More information on form regions available on MSDN here.

SQL Server Reporting Services 2008 Tutorial in 5 Minutes or "How to send my boss a report from a view quickly"

Some facts:

  • SQL Server Reporting Services were great in the past. SSRS 2008 are better.
  • MSDN is great. MSDN has lots of details. Sometimes it’s too much if you are under pressure.
  • Google usually gets me the information I want faster. Especially when I need to get something done quickly.

All in all this post is for those of you that need to learn how to use SQL Server Reporting Services fast or need to solve the above mentioned problem fast, without knowing too much about the details. I read a lot of and like these introductory posts and so now I’m writing another one, here goes.

I assume you have SQL Server Reporting Services already setup (by your grand one-and-only unmissable sys-admins or by yourself, but in the latter case you probably are not the target audience for this) and you have access to the all required tools. Talking about tools, there are three you should know of:

- RSConfigTool – (Start menu > SQL Server 2008 > Configuration > Reporting Services Configuration): What do I need it for: Troubleshooting, Finding Urls, Configuration Report Server. Having problems trying to connect. See Additional Tip #1.

- Report Manager – (http://<yourserver>/reports): What do I need it for: Managing your reports (you won’t actually see anything on a clean install yet)

- Business Intelligence Studio – (Start menu > SQL Server 2008 > SQL Server Business Intelligence Development Studio): What do I need it for: Creating and editing your reports

and of course you will need SQL Server Management Studio for managing the data the report is based upon.

(side note: This tutorial is based on the 2008 version, can’t say how many differences there are between this and the older versions.)

1. Create your views

There are ways to aggregate your data in the report itself, but it’s easier and cleaner to use SQL views to provide the data for the report and use Reporting Services only for the report. So go to SSMS and create your view.

2. Create a new BIDS (Business Intelligence Development Studio) solution based on the “Report Server Project” Template. Add a new report by clicking on the Report node in the Solution Explorer. Next we need to connect to a data source. Give it a name, click edit and connect to your database.

datasource

3. Click next and the Query Designer appears. Here you enter the T-SQL statement for your data. Ideally it’s just a “SELECT * FROM yourView” (or select each column distinctly). You can test it using ‘Run Query’. You can also choose to use data from a stored procedure if you like, just select the appropriate option.

reportdesigner1

4. Design your report. You can add elements to the report surface, by right clicking on the center surface and select them from the insert menu. The most important are Header, Footer and Table. In the Header and Footer you can add Textboxes with text or by right-clicking on them and choosing expressoin you can choose some variable input. For example page number, report name etc. In the table you can drag columns from the “Report Data” (on the left showing the data source you just added). When you are finished, you might have something like this. Click preview to get a glimpse at what your boss might get.

reportdesigner2

reportpreview

5. Now let’s deploy it to the report server. First we must set the report server url. Right-click on the solution in the Solution Explorer and click on Properties. You will see the following dialog. Change the TargetReportFolder value to something you wish and provide the TargetServerURL as http://yourserver/reportserver (not just /report!). Press save. Now right-click on the solution again and select Deploy.

 reportproperties

6. When it finishes open the url http://yourserver/report (not /reportserver!). You will see something like this. Go ahead and click on Test.Reports (or whatever you specified as TargetReportFolder) and then click on your test report. You will be greeted with the web version of your report.

webreport

7. Now your Boss will not want to go the web page to get that report, so let’s look at sending it to him per email automatically. First we need to change the security settings for connecting to the data source. In the report page, click on Properties > Data Sources. Change the “Connect using” to “Credentials stored securely in the report server” and specify an account that has access to the data. Also check “Use as Windows credentials…”.

security

8. Now you can go to Subscriptions. Click on email. Don’t have email as an option? See Additional Tip #2. Enter the recipient information as you wish and select a schedule for the sending. If you press save and encounter an error that ‘SQL Server Agent is not running’ either figure it out yourself what the problem could be or read Additional Tip #3 :). Once you have finished, lean back and let SSRS make your boss happy and in turn make you happy.

So we have seen the absolute basics of report creation. A quick and dirty introduction. This should cover your first encounters with SSRS. Hope it helps someone!

Stop reading here unless you are Troubleshooting…

Additional Tip #1:

I try connecting with SSMS (Management Studio) and it won’t connect. Maybe you renamed the server? Open RSConfigTool, go to Database > Change Database > Choose an existing report server database. Just choose the existing one, and let it run through it’s config. That should repair everything and you should be able to connect using SSMS again.

Additional Tip #2:

You don’t have email in the options for delivery in the subscriptions dialog? Probably it’s not configured. Thankfully that is very easy. You start the RSConfigTool. Connect and go to the Email tab. There you just specify a sender address and the SMTP server you would like to use. Click apply and voila. The server will automatically restart and the now the email option appears.

Additional Tip #3:

Saving the subscription results in an error message saying SQL Server Agent is not running. This is a DB or sysadmin issue, but just fire up SQL Server Configuration Manager (in the Start Menu under SQL Server 2008 > Configuration) then click on SQL Server Services, right-click on the SQL Server Agent > Properties. Go to the service tab, change Start Mode to Automatic and press OK. On the next reboot it will start automatically, but you still need to start it once for now. Right-click on the ‘SQL Server Agent’ and press Start.

Installing MiniSAP 4.6D on SQL Server 2005

So after Paris it’s back to work again and this week I need to prep a VM for a customer project. I already received a clean Windows 2003 Machine and on Monday I installed SQL Server 2005 before I went. I should have seen this coming, but anyhow today I wanted to install a Mini-SAP 4.6D.

MiniSAP (now called MiniWAS) is available for Linux as a download but the Windows version is only distributed in the shop or as part of the ABAP Objects book (I hope the program manager who made that decision never crosses my way). Anyhow, I got the CDs somehow (don’t ask) and looked at the Documentation.doc file. (Actually I of course immediatelly clicked on setup.bat and bang it crashed, but doesn’t it sound calmer when I say I looked at the documentation first?).

Seems that I have versions of the CD that contain a production bug, so after doing some manually editing in the install files (as described in the documentation) I was ready to go. It tries to install MSDE on the machine, but that fails with an (‘Instance name not valid’) but I have a big SQL Server 2005 running on the machine, so I just commented out the MSDE install line in the setup.bat and it continued.

The first error I got was a collation problem. Having installed SQL Server 2005 with the default collation SAP expected it to be SQL_Latin1_General_Cp850_BIN.

Thankfully it was a clean sql server so I only needed to mount my SQL Server DVD again and run:

setup.exe /qb INSTANCENAME=MSSQLSERVER REINSTALL=SQL_Engine REBUILDDATABASE=1 SQLCOLLATION=SQL_Latin1_General_Cp850_BIN

(you can specify SAPWD if you are using mixed and not Windows Authentication). You will be prompted:
You have chosen to re-install, and therefore overwrite the system databases. Are you sure you want to proceed? Yes! (Don’t do this on a live production server. Ever.)

Started setup again, and next I was presented with an error for a registry key it couldn’t find in ‘Software\Microsoft\MSSQLServer\MSSQLServer\Parameters’. I found the MSSQLServer node but had to manually create the Parameters node. And restarted setup.bat and this time it finished without problem! Hurray.

Next up was the GUI which the original setup tried installing but couldn’t locate the setup file. It’s in the MINIGUI folder. Once that is installed, just double click the ‘Start R3 MBS’ on the desktop, then fire up the GUI and follow the rest of the instructions in the documentation. Don’t forget to install the latest Kernel Patches from the SAP Site. Voila. Hope it helps.

TOP12 announced and what are *we* doing for the rest of the week

So a couple of hours ago the top 12 finalists were announced that rise to round 2 of the world finals. Since you are reading this – you might guess – we are not really under much pressure because we didn’t rise up to the next round. Interestingly enough though I honestly thought we were quite good this year (remember I do have quite a bit of grounds for comparison) but it seems the judges really liked us, but they liked others even more. Anyway you win a few, you lose a few and you can’t really talk about losing if you are sitting in a four star hotel near the Eiffel tour relaxing and having fun. There are 49 other teams experiencing the same and the excitement is at a bit of a low, but there is one thing I know from the last years: Cry for about half an hour and then forget it and move on. Otherwise you lose the beauty of the remaining finals.

Anyhow, I promised some pictures but I though I’d just pop them up on Flickr for everybody to see. If you are interested which interesting projects did advance try the official blog. Will I participate again next year? Who knows. It depends. I could finally get the record for most imagine cup world finals, I could finally advance to a TOP12, but on the other hand I’m getting old, it’s a lot of work (but always worth it). But I have to start balancing work life, student life and all other activities.

So you’ll probably hear more about Paris now, I’ll blog some more in the next few days. I’ll leave you with some screenshots of BioMatch.

BioMatch_Screen5 This is the newest module we developed for the world finals. An environmental simulation that can forecast which species will become endangered and why.
BioMatch_Screen4 The two standard modules we developed for the first round, which were the Bayes prediction of where the species could most likely survive and the self organizing net showing clusters of species.
BioMatch_Screen3
BioMatch_Screen1

Just for completeness in case you are interested. The application is built using WPF (my first WPF application actually) and uses a couple of data mining algorithms to analyse data aggregated from different sources (such as the US PLANTS database) to simplify it, group it and show similarities. The visualisation helps the scientists to use and understand the simplified data.

As far as press is concerned we had interviews with a french magazine, with some netherland media of course with the Austrian press OE3 and derStandard (I’ll post them when they come out). The judges generally were impressed and expressed it at the end of the sessions. In the second presentation they even thanked us personally (something I hadn’t experience before) but I’m looking forward to seeing the presentations of the others on Monday to gain some insight into why they were better. To finish off with a Soma’esque reference to a past Imagine Cup world finals.

Namaste!

The Hattrick begins or The Imagine Cup 2008 Worldwide Finals

It’s been quiet for a while due to my participation in the Imagine Cup (again). Not only have I participated in each Imagine Cup since the start:

    - 2008: BioMatch – www.biomatch.at (I’ll report some more on that of course later…)
    - 2007: Kalie – Decision making system to support students during studying.
    - 2006: MyCaps – e-Sports Framework with real-life movement integration for a healthier life
    - 2005: Gecco – Global Emergency Clinic Coordination – Fast automatic help for people requiring constant medical monitoring to break their boundaries.
    - 2004: NoName – This was the worst year by far because we had not realized there was a theme, but we still took part but did not get very far.
    - 2003: SAMANTA – System for Astute Management of Time-aware Archictectures – The beginning of it all and we had an intelligent organisation system for trade fares. (2nd place locals)

but it is also my third time at the WORLD FINALS (2005: Yokohama, Japan; 2006: Delhi/Agra, India; 2008: Paris, France). I have heard that there is a polish short film team, that I met the years before (but not this time) that have also been here three times. So I wonder if I have to participate again next year to make the record official (on the otherhand I think there may actually be some guys in the IT challenge that been here more often…).

Anyway if you are interested in why I take on this challenge every year take a look at an interview I gave to the Danish Academic Relations Manager Martin Esmann over on his blog: http://blogs.msdn.com/mesmann/archive/2008/07/04/imagine-cup-2008-torsdag-dag-1.aspx

That’s all for now, pictures will follow this evening. We have to rehearse the presentation once more. Just under 3 hours to go until round 1. Wish us luck!


Subscribe / Search


XING

 

July 2008
M T W T F S S
« Jun   Aug »
 123456
78910111213
14151617181920
21222324252627
28293031  

Twitter

Blog Stats

  • 356,722 hits

Follow

Get every new post delivered to your Inbox.

Join 57 other followers