Monday, October 19, 2009

Upcoming CDNUG Event, October 27, 2009 - Visual Studio 2010 Beta / Windows Azure Platform

Time for another Cyprus .NET User Group (CDNUG) offline event!

This is the first offline event right after the summer holidays and we decided to make it special; it features two great speakers and two great topics! To this end we have the pleasure to host two hourly sessions on two very interesting technologies.

In the first session, Karl Davies-Barrett, Developer Platform Evangelist at Microsoft Malta & Cyprus and great friend of CDNUG, will talk about Microsoft Visual Studio 2010 Beta and will demonstrate all of its great new features.

In the second session, Luka Debeljak, CEE DPE Regional Technical Lead at Microsoft Corporation, will introduce to us the Microsoft Windows Azure Platform from a developer’s perspective.

See below for event-specific details:

------------------------------------------------------
Topic 1: Introducing Visual Studio 2010 Beta
Speaker: Karl Davies-Barrett (Developer Platform Evangelist, Microsoft Malta & Cyprus)

Topic 2: An introduction to the Windows Azure Platform
Speaker: Luka Debeljak (CEE DPE Regional Technical Lead, Microsoft Corporation)

When: Tuesday, October 27, 2009.
Time: 19:00 (GMT + 2) - Cyprus Local Time
Duration: 120 minutes
Where: Microsoft Office (11 Limassol Avenue, Nicosia)

Registration: Click on this link.
For more details check our website at http://www.cdnug.net
------------------------------------------------------

If it happens and you are in Cyprus, you are more than welcome to attend this special event!!!
Read more on this article...

Sunday, October 11, 2009

Saving maintenance plan failed

If you encounter the above error message when trying to save a maintenance plan you created using the the wizard in SQL Server 2005 Management Studio (SSMS), the first (obvious) thing you should try, is to check if the latest service pack is installed and if it is not then install it!

You can check out one of my past posts on how to find out which service pack is currently installed on your SQL Server 2005 instance and on how to get the latest service pack.

However, if you are still experiencing the same problem, even in the case you have installed the latest service pack, then you can try running the sql script called "sysdbupg.sql" which can be found in the SQL Server installation directory under the subfolder "install".

This script upgrades the system database stored procedures from the RTM level. Databases which may be upgraded are:
  • master
  • model
  • msdb
Make sure before trying to execute the above script, to backup the aforementioned system databases!

A big thanks to my good friend Ioannis for bringing this hint to my attention!
Read more on this article...

Thursday, October 1, 2009

MY-TG SQL Server Community Series‏ - Session Review (Sync Framework)

On September 19, 2009, I delivered a session with topic the Microsoft Sync Framework, during the Mysore SQL Server Community Series. The exact topic was: “Flexible data synchronization with Microsoft Sync Framework”.

Further below I provide a short review for my session and I also provide the PowerPoint presentation along with the source code (C#) of my demos.

The problem domain
In the modern age of Information Technology many businesses have operations demanding a large number of their employees to work outside the office in remote locations but still being able to access corporate data. To this end, the ability to support mobile and remote workers is becoming more and more important for organizations every day.

It is very critical that organizations ensure users have access to the same information they have when they are in the office. Usually these workers have laptops, smartphones or PDAs. From these devices, users need to have access to their organization’s data which is usually stored in a central Database Server.


The old approach
The traditional way based on which mobile and remote workers access information is usually by using a VPN connection or a similar technique. Of course, in the case the connection is broken or it is not available, then there is also a disruption to the operation the worker performs. Someone may argue with that and say that there is always a way of establishing a network connection to the company. That would be great but common practice proves the opposite. It is not rare at all for communications to face problems thus leaving remote workers without access to their organization’s data. Even a short disruption to an established connection between a remote/mobile worker and the organization’s central Database can cause data integrity problems.


Introducing Microsoft Sync Framework
Microsoft Sync Framework offers a solution to the problem of supporting mobile and remote workers to continue to access their data, even in the absence of a direct connection to the corporate database. To this end, Occasionally Connected Applications (OCAs) are introduced. An OCA stores the data is on the user’s device. Data is usually stored in a SQL Server Compact Edition database. This technology, allows remote workers to continue accessing their data regardless the case where a network connection is present or not.

In order to populate the user’s local database, an OCA will need to include some Data Synchronization capabilities. Data Synchronization consists of the ability to periodically take information that is stored in the client database (such as SQL Server Compact) and synchronize changes with a server database (such as SQL Server).

The main advantage of a synchronization-based solution is that users are not longer required to have a constant network connection to corporate Database. In addition to this, the speed on which users can access the data is not any more relied on the network speed but only on the local device’s processing speed which of course, is much higher than any network speed.


Why use the Microsoft Sync Framework?
Someone might ask; “Why use a framework for this purpose?

The answer to this question is relatively easy. First of all, synchronization is a difficult task. It introduces the not so trivial tasks of data conflicts detection and resolution when data is communicated from the corporate Database to the local data store on the user’s device and vice versa. Also when data synchronization is used, interruptions and restarts have to be handled in an efficient way. Furthermore, deleted items and synchronization loops are need to be managed as well.

Microsoft Sync Framework takes care of all the data synchronization issues and among many other enhancements, it allows the developer to easily parameterize an OCA implementation in order to control how data conflicts are detected and resolved.


Sync Framework Runtime and Main Components
Sync Framework introduces two basic components:
  • Synchronization providers (source & destination)
  • Synchronization session
The source and destination synchronization providers determine the source replica and the destination replica.

The synchronization session is the component which actually controls and coordinates the entire data synchronization process between the two providers.

It is important to note that Sync Framework not only allows performing data synchronization between databases, but also allows synchronizing files/folders as well as RSS and ATOM feeds.

The supplied synchronization providers are:
  • Sync Services for ADO.NET
  • Sync Services for File Systems
  • Sync Services for FeedSync (RSS & ATOM feeds)
You can also author your own provider, but it is recommended to use the supplied providers whenever possible thus reusing tested code and easier implementing your data synchronization solution.

The following figure illustrates the Runtime of Sync Framework:


Explanation of the Runtime components:

  • Data Source: The location that stores all the information that needs to be synchronized. It can be a relational database, a file system, a Web Service, or even a custom data source.
  • Metadata: Information about the data store and the objects within that data store with respect to state and change information. It can be stored anywhere. For making it easy for the developer, Microsoft Sync Framework offers a complete implementation of a metadata store.
  • Sync Service Provider: A synchronization provider for ADO.NET, File Systems, FeedSync (RSS & ATOM feeds) or even a custom provider.
  • Sync Session: Creates a link from the source to the provider and controls the entire synchronization flow.

Synchronization Flow
The synchronization flow is the following:
  1. Sync Session Initiated with Destination
  2. Destination Prepares and Sends Knowledge
  3. Destination Knowledge used to Determine Changes to be sent
  4. Change Versions and Source Knowledge sent to Destination
  5. Local Version Retrieved for Change Items and Compared against Source Version and Knowledge
  6. Conflicts are Detected and Resolved or Deferred
  7. Destination Requests Item Data from Source
  8. Source Prepares and Sends Item Data
  9. Items are applied at Destination
For more information regarding the Sync Framework Runtime please visit the following MSDN Link.


Synchronization Scenarios
There are many synchronization scenarios which can be easily implemented using the MS Sync Framework. To this end you can do the following:
  • Synchronize Databases
  • Synchronize two file system locations (i.e. Multi-master file sync between multiple PCs, Synchronization between PCs using a USB Drive, Taking a network share offline, Maintaining a backup copy of files)
  • Synchronize Web Feeds (RSS and ATOM)
You can also implement many other scenarios as the Sync Framework is very extensible and allows you to develop and use your own components such as: Synchronization Providers, metadata stores, custom data stores, etc.


PowerPoint Presentation
Please find below my PowerPoint presentation for this session.



Source Code for Demos
Please find below the source code for my demos.

Development Environment/Prerequisites:

Demo 1: Creating a Sync Ecosystem from Scratch (Databases)
Summary: In this demo, my source replica is a SQL Server 2008 database called “SyncServerDB” which represents the Central Database. The destination replica is a Windows Forms Application (role: client) developed in Visual Studio 2008 SP1 which used SQL Server 3.5 Compact Edition SP1 for hosting the local data store. The Windows Forms Application allows the user to synchronize the client with the central database via a GUI form.

Download link for source database.
Download link for demo 1 source code.

* Before using the code, you have to reinitialize it. You can follow the instructions in this document for doing this.

Demo 2: Synchronizing Files
Summary: In this demo I used the Sync Framework for synchronizing the contents of two folders on my local hard drive in a bidirectional manner.

Details regarding the folders: Make sure you create two folders called “source” and “dest” in the “Debug” folder for this Visual Studio project. Also before running the executable project, make sure you place a sample file in one of the folders in order to see after the program’s execution that the two folders were successfully synchronized.

Download link for demo 2 source code.


* Disclaimer: The source code for the demos is intended to be used only for demo purposes. Do not use it for Production systems as it is simplified for demo purposes.


Summary
This session gave me the chance to use again the Microsoft Sync Framework. All I can say is that it was a great experience. I am actually thinking of implementing some tools using the Framework and place it to CodePlex. I will be posting updates to my blog regarding this as well.

Summing up this review, I would like to say that by using the MS Sync Framework it is very easy to implement Data Synchronization for a large variety of scenarios. With all the built-in functionality you are enabled to do more with less! Additionally, you can create your own custom components and cover even more synchronization scenarios.

Sync Framework enables the developer to easily built Occasionally Connected Systems and Sync Ecosystems by providing among other efficient conflict handling and a flexible Synchronization Algorithm. Furthermore, Sync Framework Supplied Providers can be widely used for different scenarios.

I see the future regarding Sync Framework as just great! In plain words: Sync Services on the Cloud! The project codename "Huron" enables a Sync Enabled Cloud Data Hub! Find out more on the following link.

I would like to thank the Mysore SQL Server PASS Chapter committee for inviting me to present to this great SQL Server community series! It was a pleasure to present and discuss about SQL Server and its related .NET technologies.

Drop me a line if you have any comments!

See you at another event soon!
Read more on this article...

24 Hours of PASS – Session Review (18 - ADO .NET Data Services)

On September 2, 2009, I had the pleasure to deliver a session on ADO .NET Data Services, during that great SQL Server Marathon; 24 Hours of PASS! This great event was a series of 24 non-stop live, free webcasts dedicated to pure SQL Server knowledge. The exact topic of my session was: “Building Flexible Data Services for the Web Using the ADO .NET Data Services Framework”. Yes, it is true; it was the longest titled session of the event :)

Further below I provide a short review for my session and I also provide the PowerPoint presentation along with the DB scripts and source code (C#) of my demos.

The problem domain
Many applications, and especially web applications, face a set of problems in today’s environments. For example, it is difficult to identify the different types of clients and users accessing these web applications. Each different client has its own particularities which make it difficult, if not impossible, for web applications to perfectly work with all these types of clients. This requires different web methods for each client, different paging and filtering techniques and so on.

Furthermore, during the last few years, the wide usage of the Internet enabled the massive spreading of Web Applications. To this end, a new form of web applications has emerged; the well known “Connected” applications. This new type of web applications includes Rich AJAX web applications, Flash & Silverlight applications, Mashups, etc. These applications need continuous feeding of data in dedicated data channels in order to be fast and efficient. They somehow require a separation of the data and presentation layers.


The old approach
The traditional way for enabling web applications to efficiently work with the different types of clients was to include additional logic in their code in order to cover most of the different scenarios. Though, this is not anymore an efficient way for handling the uniformity of clients which access these applications as the different types of clients are highly increased.

How about using a framework that helps you develop and access data services in a uniform way?
Such case could be really interesting…


Introducing the Microsoft ADO .NET Data Services Framework
The ADO.NET Data Services framework consists of a combination of patterns and libraries which enable the creation and consumption of data services for the web. Using the framework, it is easy to create flexible data services that are naturally integrated with the web and maintain the REST style. To this end, URIs are used to point to pieces of data and well-known formats such as JSON and XML are used for representing that data.

Interacting with your data is now uniform and easy as by using the HTTP verbs GET, PUT, POST and DELETE, you can perform any operation you like on your data.

The mappings between the above HTTP verbs and the SQL language are:

If you use the web, and specifically HTTP to provide and consume your data, you will find ADO.NET Data Services very interesting as by utilizing the enormous amounts of infrastructure that already exists to support HTTP due to the wide spreading of the Internet, you are able to easily build flexible and powerful data services fully supporting “Connected” applications which is nowadays the trend in web applications design.

The following figure illustrates the different types of clients that access data through HTTP:

You can see that there is a plethora of different clients accessing the same data through HTTP.


Why Use the ADO .NET Data Services Framework?
The answer to this question is quite simple; as “Connected” applications (Rich AJAX web applications, Flash & Silverlight applications, Mashups, etc.) are the trending type of web applications, they need the corresponding data services in order to feed them with data, without affecting their presentation layer. ADO .NET Data Services allows these applications to have a dedicated data channel which allows it to be fed with data by an ADO .NET Data Service. Usually the only line of sight from these applications, is HTTP, so using the framework makes things really simple.

With this technology, the data is moved out-of-band with the presentation and behavior information thus allowing the web application on the one hand not have any delays on the presentation layer, and on the other hand to have continuous access to its data source.


The architecture of an ADO .NET Data Service
The following figure illustrates the architecture of a data service:


At the very bottom of this architecture there are the relational and non-relational sources.
Next there is the ADO .NET Entity Framework which is used for handling the relational sources and a custom LINQ provider for handling the non-relational sources. The Data Services Runtime exists as a DLL. Next, there is the Hosting/HTTP Listener for which the out of the box implantation is WCF hosted within an ASP .NET web page (though, you can author your own listener if you like). On the very top of this architecture, there is the HTTP stack, against which you can issue HTTP commands (using the abovementioned HTTP verbs) in order to access and process your data.


Consuming a Data Service
The following figure illustrates the various ways available for consuming a data service implemented within the ADO .NET Data Services framework:


As you can see, actually an HTTP stack is enough! Of course, if you like to access your data service using higher levels of abstractions you can use JSON & AtomPub clients and even easier; Windows Data Services Clients such as .NET Framework, Silverlight 2 or 3, AJAX, and so on.


Securing a Data Service
There are several ways available for securing a Data Service within the ADO .NET Data Services Framework.

With respect to Visibility, you can use:
  • Per-container visibility control
  • Read, Query and Write options
With respect to Authentication you can use:
  • Integration with hosting environment
  • ASP.NET, WCF or custom authentication schemes
With respect to Interceptors you can use:
  • Execution before HTTP GET/PUT/POST/DELETE
  • Enabling of validation and custom row-level security policies in order to maintain the REST style
With respect to Service Operators you can use:
  • Custom entry points, e.g. /MyTags?startDate='2009-09-02'
  • Composable, follow URI scheme



PowerPoint Presentation
Please find below my PowerPoint presentation for this session.


Source Code for Demos
Please find below the source code for my demos.

Development Environment/Prerequisites:
Visual Studio 2008 SP1
.NET Framework 3.5 SP1
SQL Server 2008 SP1 (used as the relational data source)
ADO.NET Data Services v1.5 CTP1

* For all the demos, you will have to modify the connection string in the Web.config file, connection string entry in order to point to your SQL Server 2008 instance. To this end, please replace ".\sql2008" with your SQL Server 2008 instance name. Also I used Windows Authentication (trusted connection) for connecting to the SQL Server Instance.

Download link for source database.

Demo 1: Examining an ADO .NET Data Service
Summary: In this demo, we examine a pre-built data service and see how we can interact with it using a Web Browser and an HTTP debugging tool.

Download link for demo 1 (and 2) source code.


Demo 2: Building a Data Service from Scratch
Summary: In this demo I build a data service from scratch using Visual Studio 2008 SP1.
Procedure: There is not sample code for this demo, as by completing the demo, you end up to a source code identical to the source code of demo 1.


Demo 3: Consuming a Data Service
Summary: In this demo, in addition to the data service which was build during demo 2, I also create a .NET client (Windows Console Application in C#) within the same project for consuming the service using LINQ to Data Services (this is actually LINQ to Entities).

Download link for demo 3 source code.

* Disclaimer: The source code for the demos is intended to be used only for demo purposes. Do not use it for Production systems as it is simplified for demo purposes.


Summary
Summing up this review, I would like to say that using ADO.NET Data Services makes it really easy to expose your data over HTTP and thus build powerful and flexible data services.

Using URIs (entities and associations --> resources and links), HTTP Verbs for data manipulation, and the well-known and simple formats JSON and AtomPub for data representation makes it easy to build RESTful data services with all the benefits derived by using the REST style.

ADO .NET Data Services are very useful for developing AJAX & Silverlight Applications, Online Data Services, Mashups and much more.

Of course, I could not end this review without mentioning the Cloud. Many of the Microsoft cloud services expose data using the same REST conventions as used by ADO .NET Data Services. This enables using the ADO .NET Data Services Framework not only for on premises services, but also with services hosted on the cloud!

This session’s topic falls under one of my favorite Microsoft Technologies; ADO .NET - Data Access! I plan to deliver even more webcasts in the future, again dedicated to ADO .NET.

I would like to thank PASS for inviting me to actively participate to this great SQL Server event and congratulate all the people who made this event a smashing success!

Drop me a line if you have any comments!

Read more on this article...