Blog ala Vidar

SQL, AppFrame and other cool technologies

Monthly Archives: July 2009

Google features

Google is the “one and only” when it comes to search, but Google also offer a lot of other features! Jon Kristian wrote about Google Wave which is going to be released this year. In addition to this they got for example iGoogle which is a very good and customizable start page. Here’s a screenshot of my iGoogle, were I’ve got news, twitter, search, tasks etc.

In addition, there’s Gmail, Picasa (where you can upload your pictures), Docs (word on web), Talk (MSN wannabe), Calendar, Sites, Maps, Translate and many more! The one that I’ve fell in love with is Reader. This is an RSS reader where you can have one place to read about everything that you care about (at least when it comes to computer-stuff). I also use it to get notified when there’s a new episode of one of the 20 series (yes, I know.. it’s a lot) I’m watching. All this with ONE login, and it’s even auto login! Sweet! Oh, did I forget the best browser on the market? Google Chrome

Btw, did you know that Google offers a lot of features also in the search field? Here’s a couple of examples you could try out:
weather Houston
5+1
100 EUR in USD
1 meter in inches
~cabin Vågslid
define:SQL
SQL site:blogs.appframe.com

The first one will of course show the weather in Houston. The second is calculating for you. Google can do complex calculations too. Conversions are a great feature when talking to for example Americans which always uses foot, inches, Fahrenheit etc. ~cabin means it will also search for synonyms like cottage. define is used for acronyms, and the last one you only search one site

NULL in check constraints

I just stumbled over a bug in both SQL Server Engine and management studio thanks to Håvard Ravatn.

CREATE TABLE [dbo].[Table_1](
	[field1] [nvarchar](50) NULL
) ON [PRIMARY]

ALTER TABLE [dbo].[Table_1] WITH CHECK ADD CONSTRAINT [CK_Table_1] CHECK (([field1]=NULL))
ALTER TABLE [dbo].[Table_1] CHECK CONSTRAINT [CK_Table_1]

INSERT INTO Table_1 (field1) VALUES ('b')

This will actually allow you to insert ‘b’ into field1, although the check constraint says field1 = NULL. Now you’re probably thinking “has Vidar gone mad? He should know that you can’t do field1 = NULL, you do field1 IS NULL”. Well, don’t worry just yet. The reason I found this was because of a bug in management studio. If you create a check constraint for field1 where the expression is:

Field1 IN (NULL, ‘a’, ‘b’)

and then save the table, the constraint is actually stored as:

Field1 = NULL OR Field1 = ‘a’ OR Field1 = ‘b’

So, be aware of this bug.

Also, remember that NULL != NULL. One NULL value is NEVER the same as another NULL value, unless ANSI_NULLS are turned off.

I’ve reported this bug to Microsoft. Please validate it, as Microsoft fixes all bugs that has more than 5 validations: https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=478176

One thing I forgot to mention, as Johnny comments is that this is NOT the way to do things. Use “Allow null”

5 minutes interview #4 – Peter Øren

Peter has been working in Omega for 3 years now. The first time I got to have a good chat with him was at technology’s teambuilding to Hovden. That was very fun! In December 2008 Peter took over as "working chief" since Johnny’s been set to be the master of PIMS for a while.

Do you remember your first day? How was it? …. and when was it?
Yes, I remember my first day. I started up in April 2006 starting AppFrame certification program with assistance from Johnny. It was an exciting day, as it always is when starting in a new job.

What did you do before you started in Omega?
I have been working in 2 companies before I came to Omega. I first started in a small company called Globe Systems which was located in Bergen. We were developing competence mapping and personnel testing tool for large companies. I Spent 2.5 years in Globe before I moved back to Ølen/Etne. In 2003 I began in Hatteland Display working with both hardware and software development. I worked 3 years there before I got hired in Omega.

What have you been doing in Omega since you started?
When I started in Omega, the Web2 framework was on its way up. I joined the team that developed the Web framework, and my first big project was the AppFrame Grid control. I continued working with the web for quite some time. Then after 1.5 year I joined Sigmund and started working with internal applications (MarketMaker). In that period of time we were focusing on getting some of MarketMaker on Web2, but after 3-4 months we started on the AppFrame R3 framework which, as you know, ended up as the Access killer. From that time I was next in charge in Tech department. In December 2008 Johnny started up as lead of PIMS product development. I took his place and now working as Manager for Tech. dept. in Omega.

What do you think is the main difference between working with internal applications and system applications?
When working with internal applications you have a large influence on how the end-user does their daily work. And off course the development it is limited down to single applications. Developing the framework gives influence on the system developer and how they are working, which is quite different from an end user. Also when working with framework you have to consider all possible approaches that can appear since it will reflect in all applications using the control. So the code you write has very large impact in a both positive and negative way :). But it gives challenges in a very different ways.

I’ve seen a bit of web3, and I have to admit it looks AWESOME and easy to both use and develop. Could you tell us a bit about when systems engineers can start using it and what they can expect from it?
First of all we have to keep CR3 development and Web3 development separated. Web3 will not, due to limitations in VS designer, be as effective as CR3 development. When that is said I hope and expect that the developers will find it easy to do development in, and a user-interface which behaves and looks much better than what we are used to in Web2. The integrated source control and the DevConnectionString, as we are familiar with from CR3, will speed up the development very much. In addition we don’t have any own developed controls. All are based on Telerik, which gives a more robust environment.

Why did we choose Telerik instead of DevExpress on web?
Telerik has a much more powerful web control package than DevExpress. I believe that they have been working with web controls for a longer time than DevExpress. But for Win Forms DevExpress is in front of Telerik. We tried out DevExpress in a period of 3-4 months, but found it quite difficult to create a dataobject that worked well together with the grid control. In addition we had other small issues that caused quite some headache for us. So I’m really confident that we have done the correct choice.

What’s new in build 4 that’s scheduled for early August?
The August/September build will be the largest build we have had so far. It’s been 6 months since last build, and therefore we have a lot of new stuff in addition to bug fixes. For CR3 the load on demand of DLLs and publishing without the need of restart of CR3 that are the most wanted features. In addition we have quite a few other features that have been implanted in the framework.
For Web3 it is the Client Side data-binding which is high-runner. This new technology will increase the performance of applications quite a lot. We have developed a control package for the Client Side framework, and I think this will be a future proof concept that will live for quite some time.

Except programming, do you any hobbies?
I spend much time with my family. But in addition I like to play volleyball, soccer and in the winter skiing is highly preferred. I also try to play the bass whenever I have the chance.

5 minutes interview #2 – Audun Hove

I first met Audun at IRC, #linux.no@Undernet about 8 years ago. My impression was that he was a true geek. He helped me with dummy C (the language) questions and of course various Linux problems.
After working for Omega a couple of months I heard about a bet Johnny (my boss at the time) had with Audun. Was pretty cool to find out that the guy that I’ve been annoying with various questions on IRC actually worked in the same company as me!

So, Audun: How did you end up in Omega and what were you doing before that?
Before Omega I was working in a company some friends of mine and myself had started, we made software for the shipping-industry related to the new (at the time) STCW-regulations. In 2006 we eventually had to shut down due to lack of short-term income. I started looking for work and got a tip about Omega through my father who was working with Tor Erling Lunde at the time. I sent a CV and application and got called in for an interview. The interview went well and I went to Bonn in Germany to work for TGE there about a week later, in June 2006.

What’s your current position?
I’m currently technology responsible for Karl Inge’s department, 3a. I go to various clients and help out with development, currently I’m in Denmark doing some work for Maersk.

Do you have any hobbies, except computer stuff?
I manage to sneak in a bit of reading, listening to music and watching movies. I enjoy taking photos as well.

Linux or Windows?
Linux of course!

5 minutes interview #3 – Arvid Markhus

Arvid has been working for Omega for several years. He’s located in Houston, but has been in Stavanger for many years in the Statoil team. I know he’s going to get married in about a year, but except that I don’t know much about what Arvid has doing. So..

How did you start in Omega? Do you remember your first day?
I’ve been friends with Arild Røksund since high school and it was he that opened the “Omega door” for me back in February 2004. I was thrown directly to the wolves in Statoil when I started with Omega, and remember I was more nervous about the HES exam you have to take before entering the Statoil office than any exams I ever had in College for some reason. After seven months in Statoil working on the Snøvit project I started in the Statoil PIMS Support team and spent two years there before I moved to Oslo working for Aker Solutions. I didn’t spend more than six months in Oslo before I traveled to Houston for a two week trip which ended up turning into seven months! I really liked the lifestyle over here and when Øyvind Vik offered me a permanent position in Houston with Omega Project Solutions I gladly accepted that, so here I am.

What’s your current position?
I work as a Lead Systems Engineer in Omega Project Solutions, (Omega’s Houston office). Since our project with Devon ended earlier this year I have been working on several minor projects for different clients, and is right now preparing for a three months trip to Malaysia where I will start up PIMS for the “Kebangagang” project, which should be cool as they will get the latest and greatest of both CR3 and Web3.

You were in Norway a couple of months ago to get to know the new framework. What’s your opinion? Anything particular you liked, or disliked?
In Houston there is a very high focus on web, and after working with web2 it’s a true joy to be working in the new framework. Though there always are a few bugs when you are working with something as new as R3 web, Peter and Ronny shall have all honors for solving any issues rapidly. The fact that we are using 3rd party components from Telerik and DevExpress also makes the job a lot easier, as you can search their pages for tips and tricks.

What are you doing except work in Houston?
As you mention I am getting married next year! The wedding will take place in Canada where my fiancé is from, and planning a wedding in one country from a different country, in addition to coordinate with my family in a third country, you get the picture, that take some time and energy.
Houston is a big city with a rich culture life, so there is always a concert or show to attend. In addition the weather over here is quite pleasant with temperatures between 35 and 43 degrees Celsius the whole summer, so just relaxing by the pool with a few cold beers is something I try to do as often as I can too.

Hidden Windows 7 features

I’ve been listening to RunAs Radio a lot lately, and I’ve picked up a couple of new cool things. The last podcast I heard was about “hidden” features in Windows 7.

PSR (Problem Steps Recorder)
A very simple application that allows you to record your steps. This will be great for you when you can’t reproduce an error a user gets. Just tell the user to start recording, then reproduce the error and stop recording. The application will create a zip-file with a MHT file inside with screenshots, OS information+++. You should try it out!

Default printers
Notice the S at the end. If you go to “Devices and Printers” you can click on the “Manage default printers” button. Here you can set up your home printer to be the default printer when you’re connected to your home network, and an other when you’re connected to your work network!

Bit locker to go
This is a really good security thing. By group policies you can force the user to encrypt USB-sticks etc when they connect them to their computers.

Direct Access
This will sort out MUCH of the VPN problems. By using Windows 7 and Windows Server 2008 R2, you can connect to any (public) network, and it will create a VPN connection to your work network, without the user having to do anything except connecting to the public network.

Branch Cache
With Windows 7 and Windows Server 2008 R2 you can now set up a branch cache on all your offices as a file cache. If a user at a branch office downloads a file from the main office, it will download the file from the main office. If a second user tries to download the same file (from the main office), it will automatically download it from the first user (in the same branch office) that downloaded this file. Pretty neat!

Aero Shake
If you have several windows open, you can “shake” one of them and the others will be minimized

5 minutes interview #1 – Trygve Haaland

Trygve is my new boss. My first years in Omega I was running a lot back and forth to his office. He helped me understand, and solve, a lot of access-tasks. Btw, did you know that Trygve was the top contributor in the MS Access area on experts-exchange.com for a long time?! He’s always online at evenings, and we’ve had a lot of good discussions about everything from cars to .NET. Trygve is now the head of department 3E.

So, Trygve. How was your first day in Omega?
Way back in September 1993, I started working in our offices, at that time located at Nerheim in Ølen. I got a pile of MS Access (1.0) books and started self-studying to learn about databases and how to develop them. The goal was to read up as quickly as possible so that I could contribute to the development of our internal admin/accounting system. Long hours, but very interesting and the work environment was pleasant and full of humor. I had known several of the people working there, Sigmund, Lars, Arne Gunnar, Kjetil etc, from the mid 80’s and had also worked earlier both during summer vacations and after school at Futura Datasenter, Sigmund’s "pre-Omega company".

What projects have you been working on?
As you can imaging there have been a few. I was kicked to the wolves and worked for Kværner installation my first year away from the office in Ølen. This was at Kværner Rosenberg yard in Stavanger where we built a work prep, CMS, hours system from scratch. The project experience taught me A LOT. I worked in the Statoil team for some years which gave me invaluable knowledge from the multitude of modules and application we have created for them. When returning to Ølensvåg I worked on several projects, also internal applications like our email client. The later years I have worked on some larger projects including a Contractor based cost system etc. My team was extended to also include some minor customers served by a support team I lead and last year this was concretize into a separate department as part of a reorganizational process in Omega. Now I try to balance my work hours between doing development for clients and handling our employees, projects and clients from a "paper point of view".

What do you do on your spare time?
Having a family with two boys, at five and nine, there are plenty of activities and things to do in the evenings. I train the soccer team where the oldest one plays and the younger one have also started "playing". Since I am also trying to attend one or two weekly old boy’s soccer practices there are some soccer going on. My two favorite red teams, Liverpool and Brann, also gives me a lot of good times. Add to this a pack of dogs, two horses, some cats, a big lawn etc and I have no trouble filling my spare time.

What’s the most fun part of working in Omega?
It is the combination. No two days are alike, always PLENTY to learn, I get to work with my hobby (got my Commodore 64 back in 1982) and all the talented, skillful and cheerful colleagues makes it impossible not to have a good time at work.

If you didn’t work with computers, what would you work with?
A very good question with no easy answer. My education was in electronics but when I started in Omega, I had plans for a higher education in economics so I might have ended up in that direction. A trip to the movies where a bunch of us saw "Rambo III" (Sigmund is EXTREMELY fond of helicopters) ended up with the question or rather a declaration that I should rather start working for Omega instead of wasting any more time on studies 🙂

Thanks for your 5 minutes 🙂

Primary key != Clustered Index

There’s been a lot of confusion about this team. What’s the difference between a primary key, unique key, clustered index etc.
For starters, notice the keywords: KEY and INDEX
A key means that it’s used for identifying something. Primary key is the primary identifier for the ROW. A Primary Key MUST be unique, and it can not have NULL-able fields.
A unique key also ensures uniqueness, but can be defined on NULL-able fields. Although, only one NULL pr field (unlike Oracle).
So, what is the primary (and unique) key used for? Making relations between tables. To create a foreign key you first need to create a key on the parent table.
When you create a primary key, it defaults to a clustered index. This doesn’t mean that this is the best way though!
Let’s say we’ve got a Person table:
PersonID NVARCHAR(10)
Name NVARCHAR(200)
Phone VARCHAR(50)
Address ….

and so on.. PersonID will be "NordVida" (first 4 chars in last name and first name). It’s clear that PersonID should be the Primary Key, because it identifies the row.
Putting the Primary Key on this field ensures uniqueness. But, should this be a clustered index? NO!
A clustered index should be ever increasing. What does that mean? It should start on 1, next should be 2, or start with "a" and next should be "b".
PersonID will never be ever increasing, because you add Trygve Haaland (HaalTryg) which is before NordVida, then you add Werner Waage (WaagWern) which is after Trygve etc.
If you had clustered index on PersonID, this means that it has to rearrange the hole "table" (clustered index) EVERY time you insert a record.
Since the clustered indexed-fields are included in all non-clustered indexes, all non-clustered indexes also will be rearranged EVERY TIME you insert a record.

So, what should be the clustered index on this table? Many use an integer field with identity. This is a good solution, as long as you’re not importing/exporting data.
Then the identity column is just a big PAIN IN THE ***. Personally I prefer having a uniqueidentifier field with NEWSEQUENTIALID() as the default. This is unique, ever increasing and VERY nice to deal with when importing/exporting data.

Lets sum up:
My opinion is that Primary keys should be set where you’ve got your "logical keys" (in this case, PersonID). The uniqueidentifier field should be set as clustered index.

How does Windows Live Writer work?

When you first install live writer, you get 4 radio-buttons. Choose the 4th. “Other” or something like that. Then it asks you for a URL. This will be http://blogs.appframe.com/username/ This will only work after I’ve set up your blog first. Username and password will be the same as in TeamDoc.

After filling category and adding the text, you can insert a picture by clicking "Picture” under Insert on the right side. After doing that, you might want to add the blog item to a category. Then you need to go into TeamDoc and add a section to your blog-TeamDoc. Then, in live writer, click the combo box “Set category”.

To insert code, install this plug-in and click on the right “Code…” under Insert. This supports VB, TSQL, JavaScript, HTML etc.

Before you publish, you can preview your post. When that’s done, click “Publish” (in the upper left corner), and you’ll get forwarded to your blog.

You can also open previous posts to fix typos or similar by clicking file –> Open. There you’ll find recently posted, or you can search all your posts.

Under the “Blog Data” section in your TeamDoc, you can change the about page, your stylesheet (CSS), header etc. Contact me if you’ve got problems with any of these and I’ll help you through it 🙂

Bloggers bloggers bloggers!

As you might have noticed, Jarl Erik have fixed a couple of things on this site. Including the new rating-system. Would be nice if you used this so we (the bloggers) know what’s interesting and what’s not.

Also, I want to invite others to start blogging. Is there anything you want to write about? Tell me, and I’ll set up a blog for you! I sent an email yesterday asking the existing bloggers to write about a couple of topic that I would be interested in reading more about. Is there any topics you’d like to read more about, please tell me (or the others). If you tell me, I can ask others to write about them if it’s not something I feel comfortable writing about.

We use Windows Live Writer for blogging. Here’s a couple of plug-ins that are very useful:

Insert Code
Syntax highlighting, row number etc. Supports C#, HTML, MSH, Java Script, Visual Basic and TSQL
http://gallery.live.com/liveItemDetail.aspx?li=1f57bd9b-a692-4593-9e9e-e2962d9c0eee

Insert File(s)
This allows you to insert files directly into Live Writer, and saves the files automatically to our filestore.
http://gallery.live.com/liveItemDetail.aspx?li=b839fc2f-afa0-4728-8f54-cf4c0d3be8f5&bt=9

Please remember security. Do not mention server-names, details that can be exploited by hackers. Also keep in mind that our customers might be reading these blogs!