Monday, May 31, 2010

Creating a Basic Application Using the Silverlight Map Control





Create a Silverlight Project

To begin, create a Silverlight project in Visual Studio.
  1. Open Visual Studio 2008.
  2. Select File the main menu.
  3. Select New, and then Project from the menu.
  4. In the New Project dialog box, under the language of your choice (for example, Visual C#), select Silverlight.
  5. Select a Silverlight Application from the available templates and then click OK.
    clip_image002
  6. When asked, make sure the Host the Silverlight application in a new Web site option is checked. Because of URL access restrictions in Silverlight, your Web page must be hosted using the HTTP scheme for it to be able to access Bing Maps tiles. For more information about Silverlight URL access restrictions, see http://msdn.microsoft.com/en-us/library/cc189008(VS.95).aspx.
    clip_image003
Display a Map

Next, reference the map control dlls in your project and display the default map in your application.
  1. With the Silverlight project selected (not the Web project), select Project then Add Reference from the Visual Studio main menu.
  2. In the Add Reference dialog box, click the Browse tab.
  3. Browse to the location of your Bing Maps Silverlight Control installation. Open the Libraries folder, select the Microsoft.Maps.MapControl.dll and the Microsoft.Maps.MapControl.Common.dll files and click OK.
  4. Add the map control assembly to MainPage.xaml of your Silverlight project by creating a namespace in your UserControl. The MainPage.xaml now looks like this:
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl">
<Grid x:Name="LayoutRoot">
</Grid>
</UserControl>
  1. Once the map control assembly is referenced, then you can add the map element <m:Map/> to your page. Put this element within the Grid.
  2. To authenticate your use of the map control, you also need to set credentials. To do this, add a CredentialsProvider attribute to the <m:Map/> element. Set the CredentialsProvider attribute to the Bing Maps Key that you obtained from the Bing Maps Account Center. Your final MainPage.xaml looks like this:
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl">
<Grid x:Name="LayoutRoot">
<m:Map CredentialsProvider="your key"/>
</Grid>
</UserControl>
  1. Run your Silverlight Map Control application to display a default map.
Change the Map Mode using XAML

To customize the map or other UIElements, you can set properties in your MainPage.xaml file.
  1. To change the mode, or style, of the map, set the Mode of the map element to “Aerial”. Your MainPage.xaml now looks like this:
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl">
<Grid x:Name="LayoutRoot" Background="White">
<m:Map CredentialsProvider="your key" Mode="Aerial" />
</Grid>
</UserControl>
Now run your project to see the map in Aerial mode.
Change the Map Mode using C#

Alternatively you can use Visual C# to change the map mode.
  1. Start by giving your map element a name so that you can access this element from within C#. Your MainPage.xaml will look like this:
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl">
<Grid x:Name="LayoutRoot" Background="White">
<m:Map CredentialsProvider="your key" Name="myMap" />
</Grid>
</UserControl>
  1. Then in your MainPage.xaml.cs file, reference the map control namespace with a using statement.
  2. Finally, set the map mode when the MainPage is constructed. Your MainPage.xaml.cs file now looks like:
using System.Windows.Controls;
using Microsoft.Maps.MapControl;
namespace SilverlightApplication1
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
myMap.Mode = new AerialMode();
}
}
}
  1. Now run your project to see the map in Aerial mode.

You can download sample application Click here

Sunday, May 9, 2010

Methods for Debugging SQL Server queries

 

 

There are three ways to debug SQL Server 2005 queries

  • Direct DataBase debugging.
  • Application debugging
  • Debugging from a DB project

Debugging a Stored Procedure via Direct Database Debugging
Direct Database Debugging is the simplest way to debug a SQL Server 2005 stored procedure. From Visual Studio's IDE you can opt to step into a stored procedure and then step through each of its statements one at a time, inspecting and changing T-SQL variables and parameters within the stored procedure. The download at the end of this article includes a SQL Server 2005 Express Edition version of the Northwind database. I added a stored procedure called DoThings that takes a @CategoryID parameter as input and then displays all products in that category whose price is greater than the average if at least 25% of the products in the category cost more than the average. If less than 25% of the products cost more than the average, then all of the products in the category that cost less than the average are displayed. A silly stored procedure for sure, but it has a number of T-SQL statements and variables and an input parameter, all of which will help illustrate some of the debugging features.

To step into the DoThings stored procedure, navigate to the Server Explorer window, drill down into the stored procedures, right-click on the DoThings node and choose the "Step Into Stored Procedure" option from the context menu. (Note: SQL Server debugging support is only available in the Team Systems and Professional editions of Visual Studio.)

This will start the debugger and execute the stored procedure. Since DoThings expects a @CategoryID value passed in, a dialog box prompts us to provide this value. Enter the value 1 and click OK.

Execution will start at the first statement. You can step from statement-to-statement using the Step Into or Step Over commands (F11 or F10 on the keyboard, respectively), as well as add parameters and variables to the Watch window. The screenshot below shows the stored procedure while being stepped through. The yellow arrow in the margin in the left indicates what statement is currently being executed. The Watch window shows the values and types of @CategoryID and @AvgPrice.

After the stored procedure completes, the results can be viewed through the Output window.

As you can see, Direct Database Debugging is very easy to launch, use, and understand. Simply right-click on a stored procedure from the Server Explorer, choose the "Step Into Stored Procedure" option, and you're off and running.

Debugging a Database Object from a Running Application
Direct Database Debugging makes it easy to debug a stored procedure directly from within the Visual Studio IDE. In some cases, however, we would rather start debugging a database object when it is called from an ASP.NET application. This would allow us to better understand when a particular database object was invoked and its state.

This style of debugging is referred to as Application Debugging. To use this style of debugging we need to perform the following steps:

  • Add breakpoints to the database object(s) that you want to debug. A database object will only be debugged if it contains a breakpoint. For example, you cannot "Step Into" a stored procedure from application code that calls the stored procedure. Rather, you must explicitly set a breakpoint within the stored procedure itself.
  • Configure the application to debug SQL Server objects. As we will see shortly, this is as simple as checking a checkbox.
  • Update the connection string to disable connection pooling. Connection pooling is a performance enhancement that allows an application to connect to a database from an existing pool of connections. This feature, if enabled, does not correctly construct the debugging infrastructure needed on the connection taken from the pool. Since connection pooling is enabled by default, we must update our connection string to disable connection pooling during the timeframe that application debugging is being used. (After you've completed debugging the SQL Server objects via application debugging be sure to reinstate connection pooling.)
Let's tackle each of these steps one at a time.

First, open the DoThings stored procedure in Visual Studio and set a breakpoint on the first statement (DECALRE @AvgPrice money). One task down, two to go!

To configure the ASP.NET application to support SQL Server debugging, right-click on the Project name in the Solution Explorer and choose the Property Pages from the context menu. This will bring up the dialog box shown below. Go to the Start Options tab and check the "SQL Server" checkbox in the Debuggers section. Two tasks down, one to go!

Lastly, we need to update the connection string used by the application to disable connection pooling. To accomplish this simply tack on the attribute Pooling=false to you existing connection string. Assuming the connection string information is defined within Web.config's <connectionStrings> section, you would update the connection string value like so:

<connectionStrings>
    <add name="NorthwindConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;User Instance=True; Pooling=false" providerName="System.Data.SqlClient"/>
</connectionStrings>

All three tasks have now been completed! To test the application debugging, create an ASP.NET page that invokes the DoThings stored procedure. The demo available for download at the end of this article has such a page. When debugging the ASP.NET application and visiting this page, the breakpoint in the stored procedure is hit and control is delegated to the debugger. Once in the debugger we can step through the stored procedure's statements and view and edit the parameter values and variables through the Watch window, just like with Direct Database Debugging.

 

This post is based on http://blogs.msdn.com/sqlclr/archive/2006/06/29/651644.aspx and 4guysfromrolla

Wednesday, May 5, 2010

Rounded corners using CSS [with out Images]

 

This post is completely based on pure Html and css.

the implementation is completely based on mathematics – geometry :-)

to achieve this we need to write some hack in xhtml as

<div class="container">
<b class="rtop"><b class="r1"></b> <b class="r2"></b> <b class="r3"></b> <b class="r4"></b></b>
Curved coners with out images !!!!!!!!! <b class="rbottom"><b class="r4"></b> <b class="r3"></b> <b class="r2"></b> <b class="r1"></b></b>
</div>


we are putting multiple <b> tags by means of creating different lines with descending widths.


now come the css implementation ,


 we are setting different width settings for <b> tags. as 


.r1{margin: 0 5px}
.r2{margin: 0 3px}
.r3{margin: 0 2px}
.r4{margin: 0 1px; height: 2px}




i.e. r1 , the top <b> tag has less width and more margin compared to the below one.



Attaching sample source code also with this post  https://docs.google.com/leaf?id=0B9WPg7HFu_8dNGU2NGU3YzItOWVhNC00NTEzLThmYWEtMTM3NzVmNDk4ZTM4&sort=name&layout=list&num=50



Sample Preview :Clipboard01