Mittwoch, 23. Februar 2011

SQL Server 2008–Recompile all Stored Procedures

Just a useful script to recompile and check all Stored Procedures in a SQL Server Database, if you have done a lot of refactoring.

declare @Schema_Pattern nvarchar(776) = NULL -- Owner name Pattern for Like, Null for all 
declare @Proc_Name_Pattern nvarchar(776) = Null -- Proc Pattern for Like, Null for all
 
SET NOCOUNT ON 
 
-- First do the user databases specified in the control table DECLARE ProcCur CURSOR READ_ONLY FOR
            SELECT ROUTINE_SCHEMA
              , ROUTINE_NAME 
            FROM INFORMATION_SCHEMA.ROUTINES
            WHERE 0=OBJECTPROPERTY(object_id(ROUTINE_SCHEMA + '.' 
                                     + ROUTINE_NAME), 'IsMsShipped')
                        AND ROUTINE_TYPE = 'PROCEDURE'
                AND (@Schema_Pattern IS NULL 
                       OR ROUTINE_SCHEMA LIKE @Schema_Pattern)
              AND (@Proc_Name_Pattern IS NULL 
                       OR ROUTINE_NAME LIKE @Proc_Name_Pattern) 
 
DECLARE @Owner nvarchar(776)
      , @Proc  nvarchar(776)
      , @SQL   nvarchar(4000)
      , @NumP  int
      , @NumE  int
      , @myError int
      , @myRowcount int 
 
SELECT @NumP = 0 , @NumE = 0
 
OPEN ProcCur
FETCH NEXT FROM ProcCur INTO @Owner, @Proc 
 
WHILE (@@fetch_status <> -1) BEGIN
    IF (@@fetch_status <> -2) BEGIN
        SELECT @SQL = 'exec sp_recompile ''' + @Owner + '.' + @Proc + ''''
        PRINT 'Running: ' + @SQL
        EXEC (@SQL)
        SELECT @myError = @@Error        
        IF @myError = 0 BEGIN
              SET @NumP = @NumP + 1
            END
        ELSE BEGIN
             PRINT 'Error Marking ' + @Owner + '.' + @Proc + ':' + convert(varchar(20), @myError)
             SET @NumE = @NumE + 1
        END
    END
 
   FETCH NEXT FROM ProcCur INTO  @Owner, @Proc END
 
CLOSE ProcCur
DEALLOCATE ProcCur
 
 
 
 

Donnerstag, 17. Februar 2011

Mobile Technology WP7 unter Kontrolle

 

mobile-technology-cover

Heute ist in der Mobile Technology in der Ausgabe 01.2011 mein neuester Windows Phone 7 Artikel erschienen.Der Artikel gibt einen Überblick über die Windows Phone 7 Controls, zeigt Unterschiede zur Handhabung gegenüber den normalen Silverlight Controls und gibt wichtige Nutzungshinweise zu deren effektiven Einsatz.

Dienstag, 8. Februar 2011

Silverlight set initial Focus / Focus popup or ChildWindow

In our current project we had the problem, that we cannot set the Focus to a Control in an initial Login-Dialog (ChildWindow). We try some things like setting the Focus after the Loaded- or PageUpdated-Event – but nothing helps.

After some time of additional research we found out, that the original problem was the missing Focus of the Silverlight Plugin after starting the Silverlight application.

So first step we do this (“HtmlPage.Plugin.Focus” is the magic):

var loginView = new LoginRegistrationView();
loginView.Show();
 
HtmlPage.Plugin.Focus();

After this, we can use the GotFocus-Event of our Login-Form to set the Focus to the UserName-Field of the DataForm at our Login-Form-ChildWindow.

public LoginForm()
{
    InitializeComponent();
    
    this.GotFocus += this.LoginFormGotFocus;
}
private void LoginFormGotFocus(object sender, System.Windows.RoutedEventArgs e)
       {
           if (this.firstCall)
           {
               var userNameTextBox = (TextBox)loginDataForm.Fields["UserName"].Content;
               userNameTextBox.Focus();
               this.firstCall = false;
           }
       }

Sonntag, 30. Januar 2011

Windows Phone 7 Update Troubleshooting

We all waiting for the NoDo-Update – some sources announce the update around the 7th of February. But Microsoft looking forward and have now published a knowledge base article about troubleshooting problems during the update process of Windows Phone 7 (hope that there are not a lot of)

Troubleshooting problems during software update for Windows Phone 7

Samstag, 29. Januar 2011

Windows Phone 7: GPS emulator

In your Windows Phone device you have a built-in Assisted GPS (aGPS), which can be used to access location informations by using the System.Device.Location namespace. The GeoCoordinateWatcher class supplies location data based on latitude and longitude coordinates. This is nice, but if you want to develop such an application it is necessary to emulate the GPS sensor.

In this Windows Phone Team Blog a very good article can be found to achieve this goal.

Dienstag, 18. Januar 2011

Debugging Windows Phone 7 device traffic with Fiddler

Eric Law on his MSDN blog has detailed a method using Fiddler to watch your phone's data traffic over WiFi (so this won't help with that 3G issue). Primarily this is a great tool for developers to make sure their app is not using excess data in any way but it can also be useful for those who just want to know what's going on.

Debugging Windows Phone 7 device traffic with Fiddler - Fiddler Web Debugger - Site Home - MSDN Blogs

Montag, 17. Januar 2011

Data Access with Windows Phone 7

My article in the german Dotnetpro magazine about data access with Windows Phone 7, I have written with my SDX colleage Matthias (see Mind-driven development), is now out: http://bit.ly/hzYWFC