Thursday, April 8, 2010

Using Schema Comparison in visual studio 2010

Introduction

I am happy to share one of the interesting feature of Microsoft visual studio 2010, and the feature is under data named “Schema Comparison”. I am sure every now and then we need two pretty important stuff regarding database while deploy or test deploy our application’s data and those are

  • Data Synchronization
  • Schema Synchronization

In this particular post we are going to take a look at the schema comparison stuff. I am sure we have used some kind of schema comparison tool before, I my self is a big fan of red get sql belt, which has few really life saving tools and support to ease our life while working with data, but today I am bringing this because visual studio 2010 have same schema comparison option.

Process of Schema Comparison

To compare the database schema you need at least two database, this sounds stupid but still mention it you can select same data source in both target and source, which does not make sense. Any way to lunch the new schema comparison, go to top menu and find “Data” under data we have “Schema Compare” Sub menu under that we have a third level menu named “New Schema Comparison”. After selecting the menu it will bring up a new window where you would define the target database and source database. Bellow a screen shot is been given.

image

Figure: Schema Comparison Source selection

Please select both source and target database and click on “OK” to start the process after the process is been finish you would see a window like the bellow screen shot on visual studio. its simply the result and mismatch list that database have. And when you select each mismatch item you would see that required sql statement is also shown in object definition section. 

image

Figure: Schema Comparison Result

And bellow this you can find the entire script needed to update the target database, in “Schema Update Script” window. You can change the action that need to perform in the mismatch window and then click on refresh script option to regenerate the script again.

image

Figure: Schema Comparison update script

Actions to perform

You can perform the actions using the tool bar on top of the tool bar section or using menu from > data > Schema compare > [and the select any third level menu] to perform you desired action. You have the option to directly sync via write update command or perhaps you can save the generated script on a file using Export to File option. 

image

image

Figure: Schema Comparison Actions

Note

A few note before ending the post. This feature is available in Microsoft visual studio 2010 ultimate edition. which is a little bit disappointing for the developers, its such an useful tool and needed badly if we mess with data each day.

Thursday, March 11, 2010

Custom style for your Radio Button,Checkboxes and Select Lists

I was searching for some easy JavaScript code via which I can change the style of html select. Its because we often have requirement to show different style of html select. When I say custom it mean how to entirely change the look and feel of a drop down.

Searching in Google I found couple of solutions to my problem. Most of the design is done via JQuery plugin. among those I find one easy one the link is given bellow.

http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/

image

The usage is pretty simple just add the script in your project and add link to your master page or page.

Then add css for your items. example css is given bellow.

.checkbox, .radio {
width: 19px;
height: 25px;
padding: 0 5px 0 0;
background: url(checkbox.gif) no-repeat;
display: block;
clear: left;
float: left;
}
.radio {
background: url(radio.gif) no-repeat;
}
.select {
position: absolute;
width: 158px; /* With the padding included, the width is 190 pixels: the actual width of the image. */
height: 21px;
padding: 0 24px 0 8px;
color: #fff;
font: 12px/21px arial,sans-serif;
background: url(select.gif) no-repeat;
overflow: hidden;
}
Lastly add css class ‘styled’ tag to the element that you want to make custom. you can customize the script and css to get your designed theme.


"<input type="checkbox" class="styled" /> “



Both script and css is given in the above url. just download and use.



image



Note: I found a problem while using this. when I use this the auto post back feature of asp.net elements are not working. When I have the solutions will share again.



Update: You can find whole lot of html form element customization examples here. Just choose what ever best suites you. “http://www.netwaver.com/23/24-html-form-elements-customization-techniques/



Best of luck and Happy programming



Thursday, February 4, 2010

Exposing your local IIS to network in Windows XP.

Introduction

Hi, in this post I am going to share a simple knowledge about IIS. The knowledge is about how to expose local IIS to network, so that other network users in team can access and use the functionality.

In a web application development team we might want to check our web sites not only in our local pc but also from other team members machine. That's why its necessary to expose IIS to network environment. Lets say we have a web application called "myweb" normally while development if we use iis we access the myweb as "http://localhost/myweb" well it works all the time.

Lets say our developers PC is "MYDeveloperPC" we can expose the local IIS to share with team members as "http://MYDeveloperPC/myweb". If we have windows firewall enabled by default its not exposed to network. so we got to expose it explicitly. Bellow I am providing a simple screen cast.

Step 1:

Go to control panel and open windows Firewall. Now switch to advance tab, now select "Local Area Connection" and click on the settings button. After that advance settings tab will popup.

Step 2:

Bellow the advance settings window is displayed. Now select the services you want to expose to network and click ok to commit. That's it your local iis now exposed to network and your team members can access it from there pc.

Key Notes

Its a relatively pretty simple knowledge, almost every developer knows it. But still I took the liberty to share it because, one day one of our senior developer complained that his IIS can not be accessed out side his pc. Then I showed to him, where to pock.

A things must be considered, this post is related to the problem of windows firewall. If third-party firewall is installed in the developer pc. user must allow in the third-party firewall as well.

Best of luck and happy programming.

Thursday, January 7, 2010

Using the Build event of visual studio 2008

Background

Some times we need to execute some custom task just before we build our solution or project, I have no idea how others IDE do that, but recently we have gathered some experience about Visual Studio 2008, and doing these kind of task became pretty easy.

In one of our project we had to use a custom third-party component, the component is easy to incorporate in the project, but we have a problem, the component uses a d-com component which can not be added in the project, but if we keep the com component in bin directory the program runs okay. so our challenge is to copy the component before build in the bin directory of output project from the other projects bin.

Visual Studio 2008 Build Events

In Visual studio 2008 we have two build event, prebuilt event command and post build event command, post build event can be controlled with various parameters for example, post build event will raise when a successful build is happened.

image 

Figure: Visual Studio 2008 Build tab under Project properties

In our particular case we solved our problem in using pre-build event, now let us discuss a little bit more about pre-built event, you can use almost any kind of command in command line, provided that the commands don't require special permissions for executions.

In our case we have used "xcopy" command to solved the problem, there are lot of macro for execution. we used target directory as output macro, and source directory as solution macro, since its a simple problem we set the relative path of the DLL from solution path. worked okay, when we published the project we found that in publish version also contains the DLL, job done with very good time and in a good way.

Post build is almost similar like pre-build except it has some extra control, user can specify when to raise it, in the above screen shot you can see that there is a large combo at the bottom.

Here is a small example command in the for pre-build command.

If we want to copy all output files of a project to a deployment folder after post build event we have to put down the following command in the post build command line,

""xcopy "$(TargetDir)*.*" "c:\output" /S /I /F <NUL:""

Bellow i have put down a pre-build event command line input window with macro.

image

well that's all for now, please visit the references for more information, best of luck and happy coding.

 

References

  1. http://msdn.microsoft.com/en-us/library/42x5kfw4.aspx
  2. http://geekswithblogs.net/dchestnutt/archive/2006/05/30/80113.aspx
  3. http://dotnetperls.com/post-pre-build-macros
  4. http://skysanders.net/subtext/archive/2009/09/05/visual-studio-2008-build-event-xcopy-bug.aspx

Thursday, December 3, 2009

How to add scroll viewer with WPF ItemsControl?

How to add scroll viewer with WPF ItemsControl? Here is the trick. The bellow example is for displaying vertical scrollbar only. Some times we have little space and want to have scrollviewer support in ItemsConrol.

Note that to work correctly the ItemsControl need a fixed height. 

<ItemsControl ItemsSource="{Binding}">
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<ScrollViewer CanContentScroll="True" VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled">
<ItemsPresenter></ItemsPresenter>
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl.ItemsPanel>


I guess code explains everything, note that this will work on xbap, WPF, Silverlight.

Thursday, November 5, 2009

How to check if WPF control is in design mode

Probably you all know it, still sharing it with the community. The trick is pretty simple and worth knowing. Here is the summery.

Problem: The wpf designer can not render the control

Reason: In constructor of the control some data service is been called which is available only in runtime.

A method from System.ComponentModel.DesignerProperties would save our soul this time, the method name is “GetIsInDesignMode”. Using this method you can check if the control right now is been in design mode or not, and don’t call any data service if its in design mode, Isn’t it pretty simple. Bellow a sample uses is given.

if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
{
     ///your code goes here
}

References

http://msdn.microsoft.com/en-us/library/system.componentmodel.designerproperties.getisindesignmode.aspx