# Monday, October 19, 2009

The European Tour continues! I am speaking on REST and Data Access at the SDC in the Netherlands this week. Hope to see you there.

image

posted on Monday, October 19, 2009 4:12:23 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Thursday, October 15, 2009

I’ll be speaking at the CodeCamp in Cracow, Poland on Saturday. Not only will I be doing my Scrum and Data Access talks, but another speaker got sick and I will be doing a .NET Rock Interview with Richard and Carl. Should be a great amount of fun! See you there.

image

posted on Thursday, October 15, 2009 5:42:34 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Saturday, October 10, 2009

On Monday and Tuesday I will speaking at DevReach in Sofia, Bulgaria. I’ll be doing my Data Access Hacks and Shortcuts and RESTful applications with Microsoft Tools sessions as well as the Daily Scrum talk with Remi Caron.

Chris Sells is doing a keynote on Oslo and Central Europe DPE lead Luka Debeljak will be doing a keynote on Azure. Should be great. Hope to see you there.

image

posted on Saturday, October 10, 2009 6:24:12 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Friday, October 9, 2009

Here is a another pretty cool find for managing SQL Azure databases. The SQL Azure Explorer for Visual Studio 2010 Beta 1 is a neat little add-in that allows you to explore your SQL Azure databases as well as run SQL statements.

Once you have the tool installed, just fire up Visual Studio Beta 1 (I assume when Beta 2 ships the tool will be updated) and you can access the tool from the Tools|SQL Azure Explorer menu option. You have to provide your SQL Azure login credentials (you may have to put as the login your username@servername)

image

After you have logged in, you will see the Object Explorer tree. You can drill into the database objects or select the top 100 rows of a table or view.

image

You can also right click on the database and say “Open SQL Editor” and type in SQL Statements against your SQL Azure database.

image

If you are using Visual Studio 2010 beta 1 and spend a lot of time in Visual Studio, you may want to give the SQL Azure Explorer a try since you won’t have to leave Visual Studio.

Enjoy!

Technorati Tags:
posted on Friday, October 9, 2009 4:15:54 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Thursday, October 8, 2009

Last month I showed how to manually migrate schema and data from SQL Server 2008 to SQL Azure. I also mentioned the SQL Azure Migration Wizard developed by George Huey in that post. Since then George has updated the tool (currently on 0.2.7) and it now has some great features that make it far more compelling than creating and fixing scripts generated by SQL Server.

To get started, the tool will allow you to select a SQL Server database and then ask you to select which objects to migrate.

image

It will then do an analysis of your database and attempt to fix the problems. For example, if you have a table with a TEXT column, it will automatically make it a varchar(max) and will also unbind XML schemas and UDTs. It will remove keywords (like PAD_INDEX as shown below) not supported by SQL Azure.

image

After you connect to SQL Azure, the tool makes a script for you. You have the option to run the script as is, or you can save it to disk, or you can modify it in the window and run it in real time. The scripts have good comments in there telling you about some potential problems like XML data types, etc. After you play with the script, you can execute it and the tool will let you know the success or failure of the script.

image

Now that you have migrated the schema, the hard part is over. Next you can migrate the data. The easiest way to do this so far is via Red Gate SQL Compare as I showed last time or via scripting the data via the SQL Server script wizard. To get there right click on a database in SQL Server 2008’s SQL Server Management Studio and select Tasks|Generate Scripts. After you select your database you are brought to the Choose Script Options dialog. Turn off all of the other options except “Script Data” and choose on the next screen only the tables you have moved using the SQL Azure Migration Wizard.

image

After you choose the tables to move over, you can then choose to send the script to a new window. You will notice that the only thing that was scripted was the INSERT INTO statements.

image

Now select the tab that contains your query and then choose Query|Connection|Change Connection from the main menu. Enter in the login credentials you have for your SQL Azure account and then click on the Options tab and enter in the name of the database you are connecting to. After you connect you can attempt to run your query. Just make sure that your script will be compatible with SQL Azure before you run it. Meaning if you removed any XML data types, etc, using the Migration tool, you will have to do the same to your script. There is always some cleanup to run, but is pretty straight forward. For really large databases, you may want to highlight sections of the script and run it a table or so at a time to prevents timeouts to SQL Azure. You will also have to make sure that you arrange the script to sequence the INSERTs to coincide with the foreign keys constraints. SQL Server is smart enough to put Order before Order Details, but not all objects does it do this for you.

image

When you are done you can view your database using the SQL Azure Manager I talked about yesterday.

image

Enjoy!

Technorati Tags:
posted on Thursday, October 8, 2009 5:52:46 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Wednesday, October 7, 2009

As I showed on this blog a few weeks ago, SQL Server Management Studio support for SQL Azure leaves a lot to be desired. No changing databases, no object explorer, and no easy way to connect. Good thing that Maarten Balliauw and Juliën Hanssens built the SQL Azure manager. It is available here. It is listed as a proof of concept and “highly unstable” but after a few days of playing around with it, I have encountered almost no problems. The tool is available only as a click once application that runs online with no install, so you can try it out risk free.

Maarten and Julien describe the tool as: SQL Azure Manager is a community effort to quickly enable connecting to your SQL Azure database(s) and perform basic tasks…

That is an understatement, the tool is great and saves lots of time. After the brief install, I was promoted with the login screen and I put in my login credentials and was off to the races.

image

The first thing you notice is that out of the box we have two much needed features, the ability to change databases and a full fledged object explorer. You can expand to see Tables and Views, but not Stored Procedures.

image

I have a stored procedure in this database and can’t see it in the Object Explorer, so I decided to make my fist query a simple one:

select * from sys.objects
Where type='P'

A pretty awesome feature is that you can hit F5 just like you would in SSMS and get the results as you can see here. I was able to write several TSQL queries and browse the results without any problem. When you right click on a table it will give you the option to Select the top 100, Select All, or delete the object. Pretty cool.

image

Another cool feature is that you can drag a column up to the top to automatically sort. Here I sort by City in the Customers table.

image

My only issue was that after a while, the tool times out, I suspect that this is a SQL Azure thing.

The tool makes it very easy to delete objects and databases as well as create new database. (Careful with the delete database feature!!!)

While this is a 0.1.7 release, it is worth playing with. It will save you lots of time when managing your SQL Azure databases. The roadmap to a 1.0 release is to convert to WPF, move the app to codeplex, and make it more stable.

Thanks to my colleague Aditya Pendharkar at Telerik for finding this gem of a tool.

Technorati Tags:
posted on Wednesday, October 7, 2009 3:44:35 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Monday, October 5, 2009

I have just completed an amazing 8 day journey to the village of Chyangba in a remote mountain area of Nepal. Chyangba is a village of about 55 homes inhabited by the ethnic group called Sharpa. Most of you will know Sherpas as the folks who climb up to Mt. Everest, and several famous Sherpas come from Chyangba. My friend and guide in 2003 and 2008, Ngima Sherpa, comes from Chyangba and I was going to visit him. In addition, I was working with a charity called Education Elevated to help fix up a school and set up a library. While in Chyangba, I worked on the school and library for 4 days.

Getting to Chyangba

Getting to Chyangba is not easy. We had to fly on a 16 seat Twin Otter from Kathmandu to Phaplu. Phaplu has an “airport” consisting of a dirt strip and a dude with binoculars and a radio. After landing in Phaplu we trek a few hours (mostly in the dark) to our camp.

IMG_0329

Our camp was visited by some local kids in the morning and had great views of the valley. We then trek the whole next day and finally arrive in Chyangba.

Visiting the School and Library

Upon arrival, all the school children were lined up waiting for us. We then walked around the school and library for a few hours and took hundreds of photos. Imagine hiking for 7 hours and going directly into a photo shoot. :)

IMG_0372

The kids are super cute.

IMG_0490

Project Planning

We start to size up the job ahead of us. Here is a photo of an empty room we will convert into the school library.

IMG_0376

Being geeks we decide to be agile and use the scrum methodology. We decided we would re-assess the situation twice a day and see how far we get. We took stock of what furniture we had in the building (school desks, etc) and since we are MVP geeks, we decided to use a GUID system (globally uniquely identifier for Tanya and my mom, the only two non-techies I know who read my blog.)  We put the benches into four categories: good enough, reinforce,  take apart and put back together with some new wood, and ask Roger (the scrum master).  Here is a photo of a school bench with GUID # 8.

IMG_0418

Getting to Work

Roger the carpenter and general contractor (and scrum master) worked wonders. We computer geeks just hung around and he told us what to do. Before I knew it I was taking apart school chairs, benches, desks, etc, and rebuilding them. I got pretty good with a hammer.

IMG_0472

We continued for a few days, constantly reassessing. I did not think we could fix all of the furniture in the four days we had as well as build a library (shelves, tables, and desks.) But Roger kept us on target. He did have electricity from 9:30am to about 2pm each day and was able to use a power saw. Awesome. But the kids were attracted to it like moths to the light, so I had to distract them by balancing wood on my head. As the week progressed I got better and was able to balance an entire bench on my head while standing on one foot (in the Dancing Shiva position for you Yogis.)

IMG_3193

The kids started to imitate me.

IMG_0487

Sprints 6 and 7

We did two sprints a day. Sprint 6 was on day 3 and we (mostly Roger) installed the shelves. We brought about 100 lbs of books and started to stack the shelves. After that some of us read to the kids and helped them practice counting in English.

IMG_0465

Sprint 7 was awesome. We gave out all of the school uniforms to the kids. (In Nepal you can’t go to school if you don’t have a uniform.)

IMG_0496

After we give out the uniforms, the kids all ran to change and then do a little dance for us. After we celebrate and I teach some of the kids the fist bump.

IMG_0504

Leaving :(

After spending the last few hours with the kids and helping them read and count, we departed for a final meal at our campsite. The Sherpas cooked us a chocolate cake, I have no idea how they did that over a campfire. We then went to one of the local's house for a party and drank the local drinks: Chang and Roxi. They are evil drinks. Apparently it is a Sherpa custom to refill your drink immediately after you take a sip. I have no idea how much Chang I drank, but I think I can still feel it. We then turned the house into a Sherpa Disco and danced the night away to local music. (Sherpas can get down.)

The next day we had a final going away ceremony with the whole village and they put tons of Buddhist koda and flowers on us. Since we were mostly going down, we trekked the whole way back to Phaplu in one day. We treated ourselves to $5 a night hotel rooms and flew back to Kathmandu the next day.

IMG_0539

This was a great experience, we spent a week in a local village, a village not even on the map, and made a difference. For geeks, we did the best we could-which was far more than I thought we could do. I hope that the tech community can donate a lot in small amounts, it only takes $10 to buy a school uniform or a few books so a kid can go to school. You can donate here. :)

Technorati Tags: ,
posted on Monday, October 5, 2009 8:30:25 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Thursday, September 24, 2009

Those of you who know me know that I love Nepal. My first of four visits to Nepal was in 2002 and I have been hooked ever since. My Everest expedition in 2003 changed my life and my base camp expedition in 2008 was my first time acting as a professional guide. We also raised over $20,000 for charity on that adventure. I am leaving tomorrow (Friday Sept 25th) on a new challenge: building a school and library in the remote village of Chyangba in Nepal. Chyangba is a special place since it is home to my lead (sidar) Sherpa, Ngima. Ngima just summated Mt. Everest for the first time in May. Ngima has been at my side each and every trip I have made to Nepal and he is family to me.

The village where he grew up, where his mother lives, and where most of the Sherpa he hires for my trips live is Chyangba. Last year volunteers built a school there. This year we raised enough money to get a lot of books and get every kid a uniform. Now we are building a library. The structure is mostly built, we are headed there for the next 10 days to complete the project.

Joining me are:

Notice that 4 MVP are coming (including myself) representing 3.5 countries (since I am from USA but live in Hong Kong.) The four of us have decided to adopt Chyangba and will continue to return and donate to the village. I hope to create an endowment for the school and library and enable them to have internet access so the school in New York that we raised money for last year will be able to become a sister school and allow the kids to web cam each other. Next year we hope to bring running water to the village (we need $20,000 for that.)

I hope that as a community we can also help out. We are fortunate to have great jobs and great opportunity. When I told geeks in Germany this week at Basta! about my adventure, several handed me cash on the spot. (And due to the strength of the Euro it turns out to be a lot of money.) Individual members of Telerik have given me money as well and the company as a whole has supported my efforts. I spoke to the boys at arch-rival DevExpress and they are game too. If you want, you can donate here.

In addition to the 4 MVPs that are going, we have the organizers of the charity coming and Richard Campbell is bringing his wife and friend Roger from Vancouver. Roger is a carpenter, who brought about 90 lbs of tools and supplies. We spent all day today in Hong Kong looking for containers to pack the equipment in. (We found a good sturdy bag to get it all there.)

I’ll be going offline for two weeks, see you in early October….

image

posted on Thursday, September 24, 2009 9:45:33 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Wednesday, September 23, 2009

Yesterday at the BASTA! keynote I wrote an application on the fly showing how to write a WCF service and then call it from Silverlight asynchronously. Instead of posting the code, I figured that I would put up a walk through.

Getting Started

To get started fire up Visual Studio and start a new Silverlight 3.0 project. In order to use Silverlight 3.0 you will need the Silverlight 3.0 SDK installed. Once you have the new Silverlight application up and running you should have two solutions up and running, one with the Web host and one with the Silverlight XAML files. Right click on the Web project and choose Add|New Item and choose WCF Service.

image

Once you select the WCF Service, give it a name, I chose Basta1, but you can name it whatever you want. Next you will be brought into the interface file or Iyourservicename.cs. Here you have to define your POCO class as well as the method signature of your service.

In the demo I made a class of RockBand as shown here:

   1:  //POCO
   2:  public class RockBand
   3:  {
   4:    public int RockkBandId { get; set; }
   5:    public string RockkBandName { get; set; }
   6:  }

 

This is the definition of our “POCO” or “plain old CLR object” class. No attributes or any logic about the underlying database, just a simple CLR object. I am using a pretty simple design here, so if you are looking for some more complex demos or examples of using databases and ORM, check out my blog series on the Telerik WCF OpenAccess Wizard.

Now we have to define the WCF service contract. I will create a simple method, ReturnRockBands that will return a List of RockBand. Here we just define the method’s interface, we will implement the method in the service class.

   1:  [ServiceContract]
   2:  public interface IBasta1
   3:  {
   4:      [OperationContract]
   5:      List<RockBand> ReturnRockBanks();
   6:  }

Now just save the interface file and then go ahead and open the code behind of the SVC service file. We will implement the service contract interface of ReturnRockBanks (notice that I made a typo in my demo, hey you try coding in front of 500 people!)

   1:  public class Basta1 : IBasta1
   2:  {
   3:      public List<RockBand> ReturnRockBanks()
   4:      {
   5:          List<RockBand> rockbands = new List<RockBand>();
   6:   
   7:          rockbands.Add(new RockBand() { RockkBandId = 1, RockkBandName = "Depeche Mode" });
   8:          rockbands.Add(new RockBand() { RockkBandId = 2, RockkBandName = "The Smiths" });
   9:          rockbands.Add(new RockBand() { RockkBandId = 4, RockkBandName = "Britney Spears" });
  10:   
  11:          return rockbands;
  12:      }
  13:  }
  14:  }

 

This code is pretty straight forward, our class implements the interface we just created in line 1 and our method fills a List of RockBand and returns that list. We will now consume this service in Silverlight. But before we do that we have to change our WCF binding to basic in the web.config:

<endpoint address="" binding="basicHttpBinding" contract="SilverlightApplication20.Web.IBasta1">

Now just save (and compile) the project and let’s move into our client.

Building the Silverlight Client

We will create a simple Grid and a button in our XAML. When the user clicks on the button, we will call the WCF service and bind the data to the grid. Pretty simple application, but I just want to demonstrate how easy it is to do. A real application is not that much harder.

   1:  <StackPanel>
   2:  <data:DataGrid Name="MyGrid">
   3:   </data:DataGrid>
   4:  <Button Name="MyButton" Content="Push Me!" Click="Button_Click"
   5:  ></Button>
   6:  </StackPanel>

 

Since we defined a Click event for the button in line 4, let’s go into the C# code behind and call our WCF service. But first we have to set a reference to our service, we do that by right clicking on the “references” item in our solution and say “Add service reference.” Choose the reference we just created (by hitting the discover button) and we are good to go.

image

Now we have to do two things. First we have to set up a reference to our service proxy that was just created. This is done in line 3 and then we have to set an event to fire when our asynchronous call to the ReturnRockBank completes. This is done on line 4 and the method name to catch the event is called wcf_ReturnRockBanksCompleted. Lastly we call our WCF service’s method in line 6. Notice that the proxy added the “async” suffix to our method.

   1:  private void Button_Click(object sender, RoutedEventArgs e)
   2:  {
   3:      Basta1Client wcf = new Basta1Client();
   4:      wcf.ReturnRockBanksCompleted +=  wcf_ReturnRockBanksCompleted;
   5:      //call method WCF
   6:      wcf.ReturnRockBanksAsync();
   7:  }

Now we have to catch this event when it is done firing. We do that by implementing wcf_ReturnRockBanksCompleted. Then all we have to do is bind our data grid to the “result” in the event arguments (line 4).

   1:  void wcf_ReturnRockBanksCompleted(object sender, 
   2:          ReturnRockBanksCompletedEventArgs e)
   3:  {
   4:      MyGrid.ItemsSource = e.Result;
   5:  }

 

That’s it to get WCF services to work with Silverlight. When we run this and push the button, our application looks like this:

image

Now to make this a “real” application that is not hard coded, all you have to do is create WCF services for your CRUD methods and fill your POCO object with data from your database. There are tons of different approaches to doing that, you can check out some methods in my blog post here.

Enjoy!

posted on Wednesday, September 23, 2009 8:44:16 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback