Monday, November 01, 2010

Repeat header rows on each page fixed

You checked "Repeat header rows on each page" in Tablix Properties dialog box and it does not work as intended.
Here you can find explanation how to overcome this issue.





List, Table and Matrix controls are templates of the same underlying Tablix Data Region control that was introduced in SSRS 2008:

  • Table template provides ability for displaying detailed or grouped data.
  • List template provides ability to display detailed data. It also enable developers to customize layout that could look differently from the table's one. It could also use nested lists.
  • Matrix template provides ability for displaying grouped data with summary information. Columns and Rows in matrix template could be considered as SSAS dimensions. But Matrix restricts them to two dimensions per Matrix only.
That's why we see Tablix properties dialog box each time when requesting properties dialog box on List, Table or Matrix controls.


In order to make row header repeatable on each page follow steps below:

  • When in designer enter Advanced Mode


  • After entering advanced mode you are now able to see and adjust static row's properties.

  • The property you need to adjust is RepeatOnNewPage. Set it and static row (table header) will be repeated on every page.

  • Now row header will appear on every page.


"Header should remain visible while scrolling" behavior is controlled by row header static row's FixedData property



You can also adjust group row header visibility settings which appears in the Row Groups section under corresponding group using KeepWithGroup property.




But wait a minute. What do those properties on the Tablix properties dialog control do?! Repeat row headers and repeat column header options on the tablix dialog only works if there is a row header area or column header area in your report. You can identify a row header area and column header areas by the double dashed lines that separate these areas from the body of the Tablix. Thus making them usable only when Matrix template is used.




PS: I read about manually updating report's underlying XML structure when you want to get the same functionality but I would not advise you to do it until you are aware of what you are doing.


Regards,
Oleh.

Thursday, July 01, 2010

Beta exam results

Finally I have received last email with my beta exam results. This time I passed 70-513 TS: Windows Communication Foundation Development with Microsoft .NET Framework 4 

In total I have succeeded with 4 out of 5 betas. Failed with PRO: Web development.
Basically results show my every day involvement with corresponding technologies. More windows than web, communication and back end development.
Have not tried TS: Accessing Data with Microsoft .NET Framework 4 due to inconsistency of my schedule with exam availability dates and time. Will plan to take it this fall.



My complete public transcript can be viewed here. Transcript ID - 740601, Access Code - SuperOleh.


Regards,
Oleh

Wednesday, April 28, 2010

SQL Server 2008 R2 RTM

SQL Server 2008 R2 RTM'd today.


Browse FAQs, whitepapers, e-clinics and more here.

Monday, April 12, 2010

Visual Studio 2010 and .Net Framework 4.0 RTM!











As it was announced earlier today Visual Studio 2010 and .Net Framework 4.0 are publicly available with Silverlight 4.0 available later this week.

Thursday, January 07, 2010

MCTS: SQL Server 2008

New certification passed. This time I have successfully passed TS: Microsoft SQL Server 2008, Implementation and Maintenance exam.



Currently my MCTS certification stack looks like:



Regards,
Oleh

Monday, November 23, 2009

Fiddler deep dive


Microsoft PDC09


First PDC09 session I have watched is Become a Web Debugging Virtuoso with Fiddler where Eric Lawrence who is Fiddler's author unveils its origin, shows different use case scenarios, how it can be used for tuning performance, manipulating traffic, how it can be extended and finally announced availability of FiddlerCore library that encapsulates basic Fiddler functionalily (HTTP proxy) and can be utilized by applications directly.


I'm using it for quite a while but only after observing this session I understood that I was using no more than 40% of Fiddler's functionality.
Must see session for every web developer!


Useful links:
Regards,
Oleh

Sunday, November 15, 2009

Restart WPF application that is ClickOnce deployed

What do I have:
Tiny WPF application deployed via ClickOnce that is up and running all the time and like start menu it contains shortcuts to applications that will be used by users + work related statistics. Application is deployed to remote IIS and is available offline.


What do I need:
When new version is deployed application must upload latest version and restart itself. Kind of self updating application. For that it is checking every x minutes for a new deployment.


Problem:
  • Unfortunately there is no appropriate method in Application class for restarting WPF application like there is one in Windows Forms. Referencing Windows.Forms just because of that does not sound like a proper solution. If Restart method was pulled out from WPF then there should be a reason for that.
  • Starting a new process with application deployment path and shutting down current does not sound like a good idea as a new browser window will be opened. I don’t want users to be confused by any new windows that will appear without ‘any reason’.
  • Starting a new process like Process.Start(Assembly.GetEntryAssembly().Location); is good for just restarting but in case of ClickOnce deployed application it will start the same version but not new one.
  • Another point to make application self updating is that since it’s up and running all the time it needs to utilize latest critical updates that maybe time critical.



Solution:
What I thought of was to create a simple “restarter” app that will:
  • Be started after new version is downloaded.
  • Close all running applications by closing all processes by app name.
  • Contain a transparent borderless main window with a web browser control on it that will navigate to app deployment uri. It will ensure that no new browser windows will appear, no ClickOnce “Update Available” dialog will appear and latest version will start.
  • When navigated (new app started) it will close itself.
  • Encapsulate all restart logic + infrastructure (invisible web browser control).

Main Application will contains a timer that will check for new version, update current deployment if new one is available, start ”restarter” and finally shutdown itself.


Main code blocks:
Main app:
///
/// New version check routine.
/// If new version is avaialble start restarte
///
private void CheckForNewVersion()
{
  ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;
  // check for new version
  if( deployment.CheckForUpdate() )
  {
    // start restarter process
    Process.Start( "Restarter.exe" );
  }
}


Restarter is pretty simple:
XAML:
<Window x:Class="Restarter.RestartWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        Title="Restarter" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        d:DesignHeight="500" d:DesignWidth="500" SizeToContent="WidthAndHeight" Width="1" Height="1"
        Loaded="Window_Loaded" WindowStyle="None" ShowInTaskbar="False" Opacity="0" Top="-10" Left="-10">
    <Grid>
        <WebBrowser Name="ctrlBrowser" Navigated="ctrlBrowser_Navigated" Width="10" Height="10"/>
    Grid>
Window>

Code behind file has only two event handlers:
private void Window_Loaded( object sender, RoutedEventArgs e )
{
  // shutdown all running applications
  foreach( Process process in Process.GetProcessesByName( "WPF.Restart" ) )
  {
    process.Kill();
  }

  // open online application uri -> it will update app to latest version
  ctrlBrowser.Source = new Uri( "" /* Insert your deployment uri*/ );
}
private void ctrlBrowser_Navigated( object sender, NavigationEventArgs e )
{
  Application.Current.Shutdown();
}

You can download solution (.Net Framework 4 Beta 2) here or get it from file widget lower on the right panel.


Hope this helps someone.
Regards,

Oleh

Saturday, November 14, 2009

.Net Framework 4 Client Profile

WHAT IS IT:
It is a subset of .net assemblies that ‘most’ of the .net applications will require which is designed to decrease installation package size, installation time and thus overall deployment experience.
Full .net framework package should be used only by pure server applications like ASP.NET apps, WCF services, by developers who will be compiling applications (msbuild is not included in Client Profile), and by applications that are using features that are not included into Client Profile. Mainly it’s aiming development machines and web/application servers.


CHANGES COMPARING TO 3.5:
Deployment changes:

  • Installation package is currently ~30Mb and should be less by RTM.
  • Unlike .Net Framework 3.5 Client Profile it is targeting any OS version.
  • It might be redistributed via Windows Update in future. (it would be interesting to see statistics like this for example in Google Analytics but unfortunately only IE is sending installed CLR versions in user-agent string)
  • Speech assemblies are included in client profile starting from .Net Framework Beta 2. Cool! I’m using it J



FURTHER READING:
Deep dive into .Net Framework 4 Client profile:

Regards,
Oleh

Thursday, November 12, 2009

WebResource.axd empty or corrupted when Httpresponse.Filter is modified

I had a problem with WebResource.axd file that was send to client either empty or corrupted. It was a major problem as I was missing auto generated code for client callbacks.
My problem was in an old piece of code modifying HttpResponse.Filter that was updating every page body before transmission to client.


Here you can find workaround for the problem.


Hope this helps someone.
Regards,
Oleh

Saturday, November 07, 2009

Application.Restart in WPF

WPF does not provide Application.Restart() functionality like Windows.Forms does.
What is the best way to restart WPF application?


            Process.Start(Assembly.GetEntryAssembly().Location);
            Application.Current.Shutdown();


Regards,
Oleh

Thursday, November 05, 2009

Create wait gif with ajaxload

Ajaxload.info - nice and simple web page to create free animated 'progress pending' gifs:

  • A lot of types.
  • Adjustable forecolor.
  • Adjustable background color.
Regards,
Oleh

Tuesday, October 20, 2009

VS 2010 Beta 2



VS 2010 and .NET Framework 4.0 Beta 2 have been released. It's available to download for MSDN Subscribers immediately. Others should be able to download it starting from Wednesday, October 21 as it was announced.
  • Official product launch: March 22, 2010
  • Product line consists of 4 options:
    • VS Express: Web, C#, VB, C++
    • VS Professional with MSDN
    • VS Premium with MSDN
    • VS Ultimate with MSDN
  • Beta 2 has side by side support with VS 2008
  • Beta 2 has Go-Live license
Read official announcement here. Another one by Scott Guthrie


Regards,
Oleh

Saturday, October 10, 2009

Thursday, September 10, 2009

LINQ to SQL updates in .Net 4.0

What LINQtoSQL changes will be shipped with .Net 4.0?
List of changes could be found below (originally posted by
Damien):

Performance:
  • Query plans are reused more often by specifically defining text parameter lengths (when connecting to SQL 2005 or later)
  • Identity cache lookups for primary key with single result now includes query.Where(predicate).Single/SingleOrDefault/First/FirstOrDefault
  • Reduced query execution overhead when DataLoadOptions specified (cache lookup considers DataLoadOptions value equivalency)
Usability:
  • ITable interface for additional mocking possibilities
  • Contains with enums automatically casts to int or string depending on column type
  • Associations can now specify non-primary-key columns on the other end of the association for updates
  • Support list initialization syntax for queries
  • LinqDataSource now supports inherited entities
  • LinqDataSource support for ASP.NET query extenders added
Query stability:
  • Contains now detects self-referencing IQueryable and doesn’t cause a stack overflow
  • Skip(0) no longer prevents eager loading
  • GetCommand operates within SQL Compact transactions
  • Exposing Link on a property/field is detected and reported correctly
  • Compiled queries now correctly detect a change in mapping source and throw
  • String.StartsWith, EndsWith and Contains now correctly handles ~ in the search string (regular & compiled queries)
  • Now detects multiple active result sets (MARS) better
  • Associations are properly created between entities when using eager loading with Table-Valued Functions (TVFs)
  • Queries that contain sub-queries with scalar projections now work better
Update stability:
  • SubmitChanges no longer silently consumes transaction rollback exceptions
  • SubmitChanges deals with timestamps in a change conflict scenario properly
  • IsDbGenerated now honors renamed properties that don’t match underlying column name
  • Server-generated columns and SQL replication/triggers now work instead of throwing SQL exception
  • Improved binding support with the MVC model binder
General stability:
  • Binary types equate correctly after deserialization
  • EntitySet.ListChanged fired when adding items to an unloaded entity set
  • Dispose our connections upon context disposal (ones passed in are untouched)
Database control:
  • DeleteDatabase no longer fails with case-sensitive database servers
SQL Metal:
  • Foreign key property setter now checks all affected associations not just the first
  • Improved error handling when primary key type not supported
  • Now skips stored procedures containing table-valued parameters instead of aborting process
  • Can now be used against connections that use AttachDbFilename syntax
  • No longer crashes when unexpected data types are encountered
LINQ to SQL class designer:
  • Now handles a single anonymously named column in SQL result set
  • Improved error message for associations to nullable unique columns
  • No longer fails when using clauses are added to the partial user class
  • VarChar(1) now correctly maps to string and not char
  • Decimal precision and scale are now emitted correctly in the DbType attributes for stored procedures & computed columns
  • Foreign key changes will be picked up when bringing tables back into the designer without a restart
  • Can edit the return value type of unidentified stored procedure types
  • Stored procedure generated classes do not localize the word “Result” in the class name
  • Opening a DBML file no longer causes it to be checked out of source control
  • Changing a FK for a table and re-dragging it to the designer surface will show new FK’s
Code generation (SQL Metal + LINQ to SQL class designer):
  • Stored procedures using original values now compiles when the entity and context namespaces differ
  • Virtual internal now generates correct syntax
  • Mapping attributes are now fully qualified to prevent conflicts with user types
  • KnownTypeAttributes are now emitted for DataContractSerializer with inheritance
  • Delay-loaded foreign keys now have the correct, compilable, code generated
  • Using stored procedures with concurrency no longer gets confused if entities in different namespace to context
  • ForeignKeyReferenceAlreadyHasValueException is now thrown if any association is loaded not just the first

Potentially breaking changes:
We worked very hard to avoid breaking changes but of course any potential bug fix is a breaking change if your application was depending on the wrong behavior. The ones I specifically want to call out are:

Skip(0) is no longer a no-op:
The special-casing of 0 for Skip to be a no-op was causing some subtle issues such as eager loading to fail and we took the decision to stop special casing this. This means if you had syntax that was invalid for a Skip greater than 0 it will now also be invalid for skip with a 0. This makes more sense and means your app would break on the first page now instead of subtlety breaking on the second page. Fail fast :)

ForeignKeyReferenceAlreadyHasValue exception:
If you are getting this exception where you weren’t previously it means you have an underlying foreign key with multiple associations based on it and you are trying to change the underlying foreign key even though we have associations loaded.Best thing to do here is to set the associations themselves and if you can’t do that make sure they aren’t loaded when you want to set the foreign key to avoid inconsistencies.

Regards,
Oleh

Identity value management

Identity column is a column that uniquely identifies every row. It differs from a primary key in that its values are managed by the server and ( unless you specify it explicitly ) can't be modified. In many cases it is used as a primary key.

Identity value management:

Create Identity:

CREATE TABLE [dbo].[Person]( [PersonID] [int] IDENTITY(1,1) NOT NULL, [Name] [nvarchar](128) NOT NULL)

Insert Identity values:
You do not have to specify identity value when inserting new record: INSERT INTO Person(Name) values('Oleh'). It will be filled for you using current identity and increment values.
In case you specify one: INSERT INTO Person(PersonID,Name) values(2,'Oleh') you will get an error: Msg 544, Level 16, State 1, Line 2
Cannot insert explicit value for identity column in table 'Person' when IDENTITY_INSERT is set to OFF.
Instead you need to use next snippet:
SET IDENTITY_INSERT Person ON
INSERT INTO Person(PersonID, Name) VALUES(1,'Oleh')
SET IDENTITY_INSERT Person OFF

When you insert identity value explicitly and it's a primary key column then you will get an error:
Msg 2627, Level 14, State 1, Line 2
Violation of PRIMARY KEY constraint 'PK_Person'. Cannot insert duplicate key in object 'dbo.Person'.
The statement has been terminated.

Get current identity value:

  • DBCC CHECKIDENT(TableName, NORESEED) - returns current identity value
  • SCOPE_IDENTITY() - returns the last identity value inserted within the same scope(stored procedure, trigger, function or batch)
  • @@IDENTITY - returns the last identity value inserted across all scopes
  • IDENT_CURRENT(TableName) - returns the last identity value for the specified table regardless of the scope.
Update identity value:

  • DBCC CHECKIDENT(TableName, RESEED, NewSeed) - resets the identity value with provided seed
  • DBCC CHECKIDENT(TableName) - resets the identity value only if it is required
Get Seed/Increment:

  • IDENT_INCR(TableName) - returns original increment value that was specified when identity was created.
  • IDENT_SEED(TableName) - returns original seed value that was specified when identity was created.
SELECT TABLE_SCHEMA, TABLE_NAME
, IDENT_SEED(TABLE_SCHEMA + '.' + TABLE_NAME) AS IDENT_SEED
, IDENT_INCR(TABLE_SCHEMA + '.' + TABLE_NAME) AS IDENT_INCR
FROM INFORMATION_SCHEMA.TABLES
WHERE IDENT_SEED(TABLE_SCHEMA + '.' + TABLE_NAME) IS NOT NULL

Finding gaps in identity column:

  • Here you can find the original post about how you can find gaps in identity column.
Regards,
Oleh