Thursday, July 18, 2013

How to open SQL profiler in SQL Express LocalDB



SQL Profiler is an extremely wonderful tool to debug the SQL server problems. I personally love this tool very much. Recently while working with one of the project I had to deal with SQL Express LocalDB instance. According to my coding style I was very much sure that, I will need to debug at SQL level using SQL profiler to fix the issues.

As expected one of my stored procedure in SQL Express LocalDB was failing and I tried to debug it using SQL Profiler. You can open the SQL profiler in SQL Server Management Studio from “Tools” menu.

The login window appears where in you will need to put the SQL Express LocalDB server instance name. As a usual practice you may put the server name like for example, (localDB)\MyDB with connection option as Windows Authentication or with credentials for SQL Server authentication. However with this approach the SQL profiler may not open.

To overcome this problem we need to use SQLLocalDB utility. SQLLocalDB utility is command line tool which helps user to manage and perform administrative operations on SQL Express LocalDB instance. Here to connect SQL profiler to LocalDB instance we need to retrieve the correct instance name using SQLLocalDB utility. Open the command prompt and type following line in command line window.
Sqllocaldb info “InstanceName”
InstanceName in above command will be replaced by the instance name of your LocalDB server instance. The “info” command argument return you name, version, and state, last start time and most important “Local Pipe Name” of the specified LocalDB instance. The information is as shown below –
 
The local pipe name selected and reported in above command output need to be used for making the connection in SQL Server Profiler for SQL Express LocalDB as shown below –

Friday, July 5, 2013

The function import cannot be executed because it is not mapped to a store function



This is very typical error you receive when your underlying database store is changed and there is no update made to EDMX file.
For example, I imported a stored procedure in edmx and saved it. After that I change the stored procedure and do not update edmx. I run the application and at runtime the error is encountered as - “the function import cannot be executed because it is not mapped to a store function”.
This error can be resolved easily by updating the edmx. Following is procedure to resolve the error –
Open the edmx and open Model Browser. Model browser can be opened as shown below.
 
Find the required stored procedure in model browser. The right click and select option – “Delete from Model” as shown below –
 
Now right click on any area on edmx file and select the option “Update Model from Database” option. The popup containing the list of Tables, View and stored procedure will appear. Select the earlier deleted stored procedure and click “Finish” on the pop up.
Now again open the model browser and find the added stored procedure. Right click on it and select the “Edit” option as shown below -

Tuesday, June 25, 2013

Yamaha Ray – A New Step into Indian Two Wheeler Industry by Yamaha – Review and general information



The old runners of Indian roads are about to vanish now. Very popular two wheelers in scooter category like Vespa, Lambretta etc are hard to find these days on Indian roads. The all new, trendy Sports bike has replaced them in recent years. Still, an Indian mentality believes on proverb – OLD IS GOLD. The result is, people try to give new look to old bikes and try to conserve them. YAMAHA’s old bikes like RX100 are still seen on the roads.
YAMAHA bikes are of 2 strokes. That simply means the mileage of Yamaha bikes is way lower as compared to today’s leading two wheeler manufactures in India. Again Indian mentality – “old is gold”; you will find these noise making and heavy fuel drinking Yamaha bikes. The important point to note here is Yamaha never introduced and advertised their bikes as “fuel saver bikes”. In India, Yamaha is more identified for better pick-ups, speedy two wheeler bikes.
 
Yamaha’s position in Indian Market
Yamaha, originally from Japan is spread across all over the world. Two wheeler manufacturing is a small part of Yamaha organization. However, today Yamaha have made presence in whole world. Yamaha is manufacturing two wheelers since 1955. Also Yamaha is well established in Ship engines, helicopters, robots manufacturing. Since start of the company, Yamaha introduced bikes for daily use, bikes for racing and today hundreds of models are present in market.
There was huge demand for Yamaha’s two stroke bikes in India. However, Yamaha’s bikes were popular in a particular class of people. Youth with above average financial condition and who were fond of speed used to think about Yamaha bikes. With the inventions of 4-Stroke engine, fuel saving bikes came to Indian market. The Indian mentality is more leaned towards savings when it comes to money matter. The introduction of 4-stroke based fuel saving bikes changed the focus of Indian people choice for two wheeler bikes. Yamaha quickly spotted this trend and introduced 4-stroke based bikes like Spark, G5, and FZ.  However, the Yamaha still haven’t got the firm base in Indian Market. FZ caught attention, but other Yamaha bikes got very poor response.
 
Yamaha Ray
Based on previous experience Yamaha has stepped in Indian two-wheeler gearless market by introducing Ray. Yamaha Ray was launched in India in September 2012. Yamaha Ray is manufactured and is targeted for Ladies in India. The advertisement of Yamaha Ray was also broad casted to target Indian Ladies. As part of promotion Yamaha launched two wheeler driving sessions for Women. Also Yamaha Ray was manufactured in the plant which was fully operated by Women employees. After this innovative promotion also, Yamaha Ray got poor response from Indian customers. I think Yamaha follows the principle – “try try but never cry”. Yamaha launched again new Gearless two wheeler –

Friday, June 21, 2013

ListBox Data template in WPF MVVM sample



This post talks about using Data Template in WPF – MVVM. As an example I am using ListBox control. The items will be added to listbox based on data template bindings. As basic configuration create a WPF proect. Add View Models folder. I have added another project in the same solution – BusinessLayer. This actually returns list of Tasks that need to be displayed in ListBox. The final solution structure is as follows –
 

Business Layer has a class Task and TaskManager. The TaskManager class is used to create a list of Tasks which will be displayed in ListBox. The Task.cs is as follows –
public class Task
    {
        public string Name { get; set; }
 
        public string Description { get; set; } 

        public int Priority { get; set; }
    }
The TaskManager.cs contains the method to get the list of tasks. As it is very simple; I am skipping it. As part of this sample I have created a ViewModelBase class which contains the implementation of INotifyPropertyChanged  and my specific view model inherits from this base class. The code of my view model class is as follows -  
public class ViewModelBase : INotifyPropertyChanged
    {
       #region INotifyPropertyChanged implementation
        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyPropertyChanged(string propertyName)