SQL Management Studio 2008 – Query Editor Tabs

I am constantly working with multiple databases on different servers in SQL Management Studio 2008.  I am rarely working with saved files and usually with my own account, but by default, each tab just shows me the generic file names and my account.  In order easily find the correct tab I want to work with, I’ve modified the display of the editor tabs within the options to only show me the server name and the database name the query is working with.

Open Dialog:  Tools –> Options…

Location:  Text Editor –> Editor Tab and Status Bar –> Tab Text

 

This gives me query editor tabs with just the Server and Database names so I can find my way to the queries I’m looking for easier.

Building a WCF client without config file

I recently had to make a service call to a WCF service from within a K2 blackpearl code event and didn’t have access to the configuration file to configure my binding and endpoint.  I created the client using the Svcutil.exe tool and then built a basic WSHttpBinding and EndpointAddress to call the constructor of my client so I could get to work and use it.

   1: //Build a basic WSHttpBinding object
   2: var myBinding = new System.ServiceModel.WSHttpBinding();
   3:  
   4: // Build the Services EndPoint.
   5: var myEndpointAddress = new System.ServiceModel.EndpointAddress(webserver + "/Services/MyWCFService.svc");
   6:  
   7: // Create a WCF Service Client instance.
   8: MyWCFServiceClient client = new MyWCFServiceClient(myBinding, myEndpointAddress);
   9:  

This worked for a little bit, however, it turned out my EndpointAddress was a little too simple when the application pool was changed by our administrator to run under a domain account’s credentials and I started receiving the error below.

System.ComponentModel.Win32Exception (0x80004005): Security Support Provider Interface (SSPI) authentication failed. The server may not be running in an account with identity ‘host/servername. If the server is running in a service account (Network Service for example), specify the account’s ServicePrincipalName as the identity in the EndpointAddress for the server. If the server is running in a user account, specify the account’s UserPrincipalName as the identity in the EndpointAddress for the server.

To fix the problem, I had to tweak how I created my so that I passed in a DNS identity of the local system.  The code below is the code that got things working again.

   1: //Build a basic WSHttpBinding object
   2: var myBinding = new System.ServiceModel.WSHttpBinding();
   3:  
   4: // Build the Services EndPoint.
   5: var myEndpointAdd = new EndpointAddress(new Uri(webserver + "/Services/MyWCFService.svc"),
   6:      EndpointIdentity.CreateDnsIdentity("localhost"));
   7:  
   8: // Create a WCF Service Client instance.
   9: MyWCFServiceClient client = new MyWCFServiceClient (myBinding, myEndpointAdd);

Telerik ASP.NET AJAX – Giving focus to a DatePicker after AJAX callback.

I had a form with three Telerik DatePickers controls and had enabled postback on the first two to perform some server-side work.  The sample code attached is just setting the minimum date for the other DatePickers on the form.  After returning from postback, I expected the next DatePicker to have focus, but I could not get it to happen.  I sent the Telerik support team a message asking for help and the solution came quick and was very simple:

    protected void RadDatePicker1_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
    {
        if (e.NewDate.HasValue)
        {
            RadDatePicker2.MinDate = e.NewDate.Value;
            RadDatePicker3.MinDate = e.NewDate.Value;
            RadAjaxManager1.FocusControl(RadDatePicker2.DateInput.ClientID + "_text");
        }
    }

    protected void RadDatePicker2_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
    {
        if (e.NewDate.HasValue)
        {
            RadDatePicker3.MinDate = e.NewDate.Value;
            RadAjaxManager1.FocusControl(RadDatePicker3.DateInput.ClientID + "_text");
        }
    }