Pages

Ads 468x60px

Social Icons

Featured Posts

Search

How to close all connections to a MSSQL database

Monday, 5 September 2011

This script closes all connections to MS SQL database

USE master;
GO
ALTER DATABASE dbName
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE dbName
SET MULTI_USER;
GO

Animated iPhone-style ImageButton with Silverlight 4

Tuesday, 5 July 2011

In this article I am presenting a way to create animated iPhone-style ImageButton control in Silverlight 4. Button will have icon on it, rounded corners and will zoom-in/zoom-out on hover. It will be done programmatically, with very minimum amount of XAML.

I start with creating ImageButton class. I use ButtonBase as base class:

Class declaration

I want my button to contain rounded rectangle with shadow and image on it. I add these items in constructor:

Class constructor

Now my control contains rectangle and image laid out over a grid to ensure proper items positioning. Next step is to add animation to enable zoom-in/out on hovering. This can be achieved with storyboards and double animations:

Animations

To start animations I need to start animations when mouse cursor enters or leaves control:

Events

Very last step is making ImageSource property "bindable" so you can specify image from XAML. In order to do this I register new dependency property on my class:

Dependency property

The control then can be used in a following way:

Usage

And ready controls looks like this:

Final effect

 

Using Sets in .Net

Monday, 27 June 2011

Great post by James Michael Hare I came across about using Sets in .Net. Definitely worth taking a look.

http://geekswithblogs.net/BlackRabbitCoder/archive/2011/02/03/c.net-little-wonders-the-useful-but-overlooked-sets.aspx

WCF Custom tool error: Failed to generate code for the servicereference.

Thursday, 23 June 2011

Very recently, building multi-tier application involving Silverlight front-end inter-operating with WCF back-end, I encountered very odd, yet annoying behaviour of Visual Studio 2010. I was building new functionality using Telerik RadMap for Silverlight control that was to display some spartial data supplied by WCF service. To achieve this my Silverlight application had to reference few Telerik assemblies (Telerik.Windows.Controls.DataVisualization.dll). What is important is fact, that Service Reference for WCF service had been there already, project built and everything was working nicely, until I added extra method to WCF. After using "Update Service Reference" VS command, I started getting following error.

WCF error Screenshot no.1

Lack of further details with regards to this error and appropriate feedback from Visual Studio certainly does not help to get to the bottom of the problem, however after some investigation it turned out that one of Telerik assemblies caused this problem. When VS2010 creates service reference, default settings are that it should "reuse" all available types in reference. Excluding certain types from serialization allows service reference to be added successfully.

WCF error screen 2

I hope this helps anybody who got stuck with this problem.

SQL Data Types vs. C# Data Types

Friday, 15 April 2011

This article is just a reference of SQL Data Types to C# Data Types.

SQL Server data typeCLR data type (SQL Server)CLR data type (.NET Framework)
varbinarySqlBytes, SqlBinaryByte[]
binarySqlBytes, SqlBinaryByte[]
varbinary(1), binary(1)SqlBytes, SqlBinarybyte, Byte[]
imageNoneNone
varcharNoneNone
charNoneNone
nvarchar(1), nchar(1)SqlChars, SqlStringChar, String, Char[]
nvarcharSqlChars, SqlStringString, Char[]
ncharSqlChars, SqlStringString, Char[]
textNoneNone
ntextNoneNone
uniqueidentifierSqlGuidGuid
rowversionNoneByte[]
bitSqlBooleanBoolean
tinyintSqlByteByte
smallintSqlInt16Int16
intSqlInt32Int32
bigintSqlInt64Int64
smallmoneySqlMoneyDecimal
moneySqlMoneyDecimal
numericSqlDecimalDecimal
decimalSqlDecimalDecimal
realSqlSingleSingle
floatSqlDoubleDouble
smalldatetimeSqlDateTimeDateTime
datetimeSqlDateTimeDateTime
sql_variantNoneObject
User-defined type(UDT)user-defined typeNone
tableNoneNone
cursorNoneNone
timestampNoneNone
xmlSqlXmlNone


 

Most Popular