How to use sqlserver CE 3.5 in ASP.NET

That's look easy, but it is not at all ! thanks to Olivier Huet of Winwise for help me on this.

First, you should know that sql compact edition is not do for work in asp.net !!! That's strange for me !


So for use it in ASP.NET you must put in your global.asax, in ApplicationStart:

AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting",true);

That's all ? no !
Proud of yourself, you put a gridview, a sqldatasource,and run. That's don't work.
What's the problem ? the problem is the Wizard is out of date !
So,for that's work, go to your webconfig.xml (i know,we don't like that) and change your connection string by:
providerName=System.Data.SqlServerCe.3.5 />

Now that's work. (and I lost 4 hours of my life on it,thanks the wizard :( )





How to slim your flex project!!!

Flex is great but a little too big : 1 mega for have all  libraries. For a small project ,that's not very good,So I find a magical option :



With this option, the flex library will be linked with your swf, so :
  • ONE swf, not many as usual
  • All not used part of library will be erased of your SWF !
On my small project, with embedded font, sprite, mxml, it is from 1300kb to 432kb  ! 3 times less !
Use it without any restriction !

Create a star rating component in Flex

On http://cookbooks.adobe.com/post_Create_a_star_rating_component-561.html , you can see how to do a rating component with star, who is fashion now. The only problem is this componant is static, means,u can't rate yourself. So i did a little change to the component :

<?xml version="1.0" encoding="iso-8859-1"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
    horizontalScrollPolicy="off" verticalScrollPolicy="off">
   
    <mx:Script>
        <![CDATA[
            [Bindable]
            public var rating:Number = 0;
            public var i:int = 0;
            protected function starIcon_clickHandler(event:MouseEvent):void
            {
                rating=int(event.currentTarget.name);
            }
        ]]>
    </mx:Script>
   
    <mx:HBox horizontalGap="1" verticalCenter="0">
        <mx:Spacer width="4" />
        <mx:Repeater id="stars" dataProvider="{[1,2,3,4,5]}" count="5" >
            <mx:Image id="starIcon" name="{i++}" click="starIcon_clickHandler(event)" width="13" alpha="{(rating >= stars.currentIndex) ? 1 : .35}" source="@Embed('StarIcon.swf')" />
        </mx:Repeater>
        <mx:Spacer width="4" />
    </mx:HBox>
</mx:Canvas>
   
As u can see,i use a strange tips: i stock the value in the name! this look ugly but that's save my life many time yet ^^

(for StarIcon.swf or sample of use,it is exactly the same as Adobe website, so i don't copy it here).