Tuesday, June 26, 2012

SqlCeException: The specified table does not exist [xxxxx]

Today I spent almost 2 hours just to find out what is the cause of the issue about keep getting SqlCeException: The specified table does not exist [xxxxx]
Here is story.

I intended to create a local database for my phone application, hence I am following the MSDN guide. http://msdn.microsoft.com/en-us/library/hh202876(v=vs.92).aspx#BKMK_CreatingtheDatabase

I was reading the guide while writing my own application with some modification until everything are ready for testing.

Then, when the code run until:
var watchListInDB = WatchDB.WatchTable.Select(x => x);
Watches = new ObservableCollection<Watch>(watchListInDB);

Note: WatchDB is my Database Context.

The error hit at the LINQ Select extension method. I re-read the whole guide again and again just to make sure nothing is missed out. So, here are the things you need to take care of if you are running into the same problem too.

1. Database context had been created in App.xaml.
using (WatchListDataContext db = new WatchListDataContext(WatchListDataContext.DBConnectionString))
{
  
if (db.DatabaseExists() == false)
   {
     db.CreateDatabase();
   }
}
2.  In your database  context, you have your table property declared.
public class WatchListDataContext : DataContext
{

   public static string DBConnectionString = "Data Source=isostore:/Database.sdf";

   public WatchListDataContext(string connectionString) : base(connectionString)
   { }

   public Table<Watch> WatchTable;

}
3.  In your entity object, do not use unsupported data type in the class property as table column. This is my actual root cause of problem. My WatchList property/table column is a List<int> type which is not a valid data type. The SqlCeException message saying the specified table does not exist is not related to incorrect declared data type for my table column here!!! For the list of supported data type, refer to this: More Detail

Wrong example. generic list is not supported data type:
[Table]
public class Watch : INotifyPropertyChanged, INotifyPropertyChanging
{
  private List<int> _watchList;
  [Column]
  public List<int> WatchList
  {
    get
    {
      return _watchList;
    }
    set
    {
      if (_watchList != value)
      {
        NotifyPropertyChanging(
"WatchList");
        _watchList = value;
        NotifyPropertyChanged("WatchList");
      }

    }
  }
}

4.  Final thing, clean your project and then rebuild! It makes a difference!!!

Monday, June 18, 2012

Windows Phone with Windows Azure - Part 1



Normally, when we are creating a sophisticated phone app, we need to have our phone app communicate with some servers to perform some logic and data keeping. Hence, we need to host the services somewhere that allow the phone app to be able to communicate with. So, the main challenge is the service must be running and available in 24/7 and accessible from anywhere.


Therefore, what I need are:
1. WCF to provide web services for my phone app
2. Windows Azure to host my WCF service for 24/7 availability and accessible at anywhere.
3. SQL Azure to keep my data.

Windows Azure
It is a cloud computing service which is provided by Microsoft. Currently, Microsoft provides 3 months free trial for Windows Azure. We can take the advantage now to learn how to host a WCF service in Windows Azure which let your phone app to consume. More Detail

SQL Azure
It is a SQL server database service that host in cloud. SQL Azure come with the 3 months free trial Windows Azure, therefore, we can create our database there. But, mind you, there are some differences in  SQL Azure and MSSQL, especially some data types and features are not available in SQL Azure but MSSQL.

Warning: The service pricing is base on the number of hosted instances, instance size, database size, bandwidth, etc. Something like these need to be taken care of when the free trial period has ended, just to ensure your money is not burning a hole in your pocket. More Detail

Next, how to host WCF in Windows Azure? Will post it up in Part 2.

Windows Phone Development

Recently, I have been very interested in Windows Phone application development and keep doing research about it everyday after my daily job.We all know that in the current mobile industry, the phone operating systems available in the market now have iOS, Android, etc but why pick Windows Phone?

Reasons:
1. I am C# literate and I love C#.
I have been using C# since the beginning of my career. I would want to focus mastering it instead of learning all the other programming languages but not able to master all of them. In the end, I am expert in one thing instead of beginner of everything.

2. Windows Phone SDK provides all the libraries we need to develop an apps very quickly.
For those who experience in Microsoft .net framework knows that we can write code or develop application very quickly because one simple line of code can produce multiple results. The only drawback is we do not know what's happening behind the framework. :) Well, if you are a result oriented person, you would not care about it unless it hits some performance issue, then you will rage and curse Microsoft.

The advantage of speedy development in Windows Phone actually helps to tell the idea of your application can be success or fail. When the required development time is low, it means cost is low and risk is low too. Imagine you can create multiple applications with different business idea quickly to give it a trial and error way to test the market response at lower cost.

Get Started
Alright, let's get back to code. What do we need to get started?
1. Of course, Visual Studio.
2. Download and install the Windows Phone SDK 7.1. (Some may confuse with the SDK version. if you plan to create an app for Windows Phone 7.5, and this is the correct and latest SDK unless Windows Phone 8 SDK has released)
3. Download and install the Windows Phone SDK 7.1.1 Update.


Let's start having fun and play around with Hello World!


Thursday, June 14, 2012

Introduction

I am fortunate to have a mentor and she suggested me to create a blog to write down all the problem and blocking issue which I had experienced while writing code.

I find it may be is a good idea. If I encounter the same problem again, I can come back to my own blog to recall the solution. Also, this blog may help those people who encounter the same problem like me.

Alright, let's get started.

Send Transactional SMS with API

This post cover how to send transactional SMS using the Alibaba Cloud Short Message Service API. Transactional SMS usually come with One Tim...