Thursday, December 18, 2008

Linq Where not exists query

Today I needed a where not exists query in my linq to objects.

Fortunatly I found it using the google :)

Suppose we have 2 lists, the first of a dummy class with properties Id and Name, the second of another dummy class with properties Id and Color (just so they are different)

We can perform a 'where not exists' query as follows :

var OnlyInFirstQuery = (from item1 in list1 select item1.Id)
.Except
(from item2 in list2 join list1Item in list1 on list2.Id equals list1Item.Id select item2.Id);


This will give us a list having only the items in list1 that do not exist in list2, just as I needed.

Thursday, October 9, 2008

Using Internet Explorer 6 on vista

There is probable a few people who would want to run ie6 on vista,
probably the webtesters (like me), or people who don't like ie7 (like me) but do not want to use opera or firefox (unlike me). And since the normal XP portable editions do not work, it seemed there was no answer.

Searching the google did not reveal much,
only that a lot of people were trying the same thing.

Luckily I found a great program IETester which makes this possible
(I did not test yet if it does everything IE6 does, but for my case, it was perfect).

the link is : IETester homepage

This program allows you to run your (or other) sites in
internet explorer version 5.5, 6, 7 and since the latest version 8 beta 2.

I hope this helps somebody!

Wednesday, October 8, 2008

Window opened from javascript

When using javascript to open a window, it appears on top.
When this window loses focus (gets in the background),
and the user clicks the link again, the window is reloaded,
but does not get the focus again.

Since for some people this is important, the solution is to make sure the opened window has the focus :

var openedWindow = window.open("someurl", "somewindowname");
openedWindow.focus();


This will refocus the opened window.

Thursday, August 28, 2008

Internet Explorer 8 Beta 2

Internet explorer 8 Logo
Microsoft has opened up the second beta for Internet Explorer 8

Some new features are :
- Accelerators : Select some text and a new Icon pops up, allowing you to search it with Google, mail it, ...
- Search bar improvements : Sizable, and it can show the first result for seaches on eg. wikipedia
- Web Slices
- Stability : Crash recovery and each tab has its own thread, so crashes should close only one tab.
- Tab groups : When opening a link from a tab, both tabs will get a color, indicating at a glance which tabs belong together.
- Inprivate Browsing (a.k.a. the porno modus) : When activated IE will not remember any cookies, or leave traces from the sites you have visited.
- And more (click here for the tour)

I installed it on vista, and it seemed a little faster (maybe my perception). Tabs groups seems very nice and useful. The first look is very nice, better than IE7, but I guess it will not yet replace my Opera :)

You can download the beta :
Here for XP
Here for Server 2003
Here for 64 bit XP/Server 2003
Here for 32 bit Vista/Server 2008
Here for 64 bit Vista/Server 2008

Enjoy :)

Hug a Developer Today



for larger size : Click Here

Tuesday, August 26, 2008

Linq To SQL Stored Procedure returns an Int

Today I was using Linq To Sql to execute a stored procedure wicht returned results by using a temporary table and dynamic sql (not my stored procedure)
Suprisingly enough when I dropped the procedure on the dbml file,
it generated a function with the return value typed as integer.
As it turned out, linq to sql and temporary tables don't play nice.
And since the database was a sql 2000 db, using table variables was not possible.

The solution turned out to be simple enough,
replace the stored procedure with a dummy one that returns the fields your normal procedure will return (names and type).
Then drop this stored procedure on the dbml file.
This will generate the correct return type for your procedure,
then simple alter the stored procedure to the correct one.

Hurrah, we can now use linq to sql to use our difficult stored procedure.

Wednesday, July 16, 2008

Clipboard problems

Today I when I copied some text,
I couldn't paste it anywhere.

Usually I just use the shortcut keys,
but to test it now, I used the contextmenus.
Copy (or cut) appeared just fine, but when I wanted to paste,
the item was grayed out in the menu.

Looking for the clipboard viewer,
I located it in c:\windows\system32 folder, named clipbrd.exe.

As I started it, it gave me the following error :
The ClipBook service is unavailable or is not started.
Contact your system administrator to have this service started.


All fine and well, but what a weird error, looking at the clipbook service description I found :
Enables ClipBook Viewer to store information and share it with remote computers.


Not exactly what I needed, as remote computers or the clipbook viewer were not my target.

So I just clicked OK,
and tested the viewer,
and 'lo and behold my clipboard functions were working again and I could copy and paste as I wanted.

Monday, June 16, 2008

Opera 9.5 Released

Opera has released it's new desktop version.

Opera 9.5 beautifully engineered

New features contain :

- Faster speed : up to 2 times as fast as the already fast 9.2x builds
- Opera Link : Sync your bookmarks between your desktop(s), opera mini and more
- Fraud protection : According to the company, it is "the first publicly-available browser to protect you from malicious software on the Web." Opera's protection is assisted by Haute Secure, Netcraft, and PhishTank.
- A brand new skin

And of course it is still free. Just click the image above to go to the download site.

After more than a year of testing the alpha / beta / RC builds,
I like the new version, it is much faster,
my only gripes with the new version were :
- When I installed it changed something so that I could no longer just type my search query in the address bar (luckily there is a quick fix : tools, preferences, search tab, edit google properties and check the use as default search provider)
- The close buttons are small (not really a problem as I use mouse gestures)
- The add tab button is moved from the left to the right of the tab bar (but that was also a small change)

So after a small test weekend I like the new version and have not encountered any bug.

Happy surfing!

Edit : 9.51 was released and it fixes a good number of problems users were having with 9.50, just click the banner and you will get the new version.

Monday, June 2, 2008

Newest addition to the family

Yesterday we decided to add another member to the family,
abut the largest we have to day :)

Our newest member is Hector, the Shire horse.
(Yes they are large, but I like large horses and I like their character, just don't put your toes under the horse :))

Hector is one year old, but is already a decent size
(about 1m60, or in hands : 15.3 hands, or for you americans : 5.25 feet)



More pictures can be found : Here

Thursday, May 15, 2008

Visual studio 2005 toolbox icons messed up.

When I started VS 2005 today I noticed all my icons where messed up :



This makes finding the right control a little harder.

The solution is quite simple : Right click the toolbox and choose reset toolbox,
and presto , icons back.  Unfortunatly this also removes any custom items and tabs in the toolbox.

I also read that deleting all tlb files in  C:\Documents and Settings\_username_\Local Settings\Application Data\Microsoft\VisualStudio\8.0 can work, but did not try it myself.
I don't know what other things might be removed when you delete these files, so be carefull!

 

Wednesday, May 7, 2008

Problem adding files to deployment project

For some time now I have had problems adding files to the file system editor portion of a deployment project.

When I right clicked, add file, browse for a file, any file (dll / jpg / xml / txt / ...)
It would not add this file to the project,

Luckily there are workarounds for this issue (no definite fix found yet) :
- the simplest is just closing and reopening visual studio
- Rebooting your pc may also work
- Adding a shortcut to the file (which will add the file also), and deleting the shortcut (I have not tried this yet myself)
- Resetting your visual studio settings can also help (also haven't tried this myself)
- Some even say that reinstalling fixes this problem (which will ofcourse open & close visual studio and reset the settings ;-) )

Monday, May 5, 2008

Getting the temp folder in c#

Another reminder to myself :

To get the temp path in c#, the most used option I have seen is :

string tempPath = Environment.GetEnvironmentVariable("Temp");

which works ok most of the time, but personally I don't like to pass string variables around,
so I went looking for something as :
string tempPath = Environment.GetFolderPath(SpecialFolder.Temp);
which ofcourse does not exist.

But as with google as a friend, I found the best way (for me) :

String tempPath = Path.GetTempPath();

(always in the last place you look of course ;-) )

Using double quotes in c#

As a 'convert' (rather forced) from VB.NET to C# I always miss how to use the double quotes in a string, so here just as a reminder to myself :
use the @ symbol before the string or doubling the quotes won't help:

string myString = @"SomeText which needs a ""quote";

ofcourse, at the beginning of the string or the end of the string just triple the quotes :
string myString = @"SomeText which needs some ""quotes""";

But the most important is : use the @

Thursday, February 14, 2008

Connecting to an Access Database in Visual Studio 2008 Server Explorer

Trying to connect to an MS Access DB from the visual studio 2008 Server Explorer gave me a little surprise to see that the window I got to create the connection only gave me the possibility to type in the connectionstring myself.

Trying several possibilities, the test connection button always cleamed the connection was OK, but when clicking OK i received the following message :

format of the initialization string does not conform to specification starting at index 0
After a long search, the solution was found, something is incorrect in the registry :
- Open the registry using regedit
- Find the  "HKEY_CLASSES_ROOT\CLSID\{F9AE8980-7E52-11d0-8964-00C04FD611D7}"  in the tree
- Check if there is a subkey named ProgID there, if there is, you are not having the same problem as I had, but be sure to check the value

If the key is not there, add it :
- Right click the node and click new, key
- Name it ProgID
- Select the newly created key
- In the main (right) pane, doubleclick the "(Default)" value
- Set its value to "MSIDXS.1" (without the quotes ofcourse).

Now when you create a new connection to an access DB, you can use the correct window.

Tuesday, February 12, 2008

Clearing an Infragistics WebDateChooser

Clearing an Infragistics WebDateChooserThe infragistics webdatechooser is a very handy control for your website, easy to use and, as all infragistics controls, very configurable.

The only problem is when you filled in a value and want to empty the value, it retains the previously selected value. To really set the value to null, we can use its EditKeyUp event and a little javascript :

Change the control definition to (controlnames have been altered to protect the innocent) :
<igsch:webdatechooser id="wdcMyChooser" runat="server">
...
<clientsideevents editkeyup="webDateChooser_EditKeyUp">
<igsch:webdatechooser>


The name was kept generic, so that this function can be used for more than one webdatechooser on a page (or in an external javascript file or … )


Now all we have to do is add the Javascript function :

function webDateChooser_EditKeyUp(oDateChooser, keyCode, oEvent)
{
if (oDateChooser.getText() == "" oDateChooser.getText() == null)
{
oDateChooser.setValue(null);
}
}

And that is all there is to it, when the user clears the text from the wdc, the value inside is also cleared. At a postback we get the null value we wanted.