Tuesday, October 15, 2013

Great blog post - maintaining software


This blog post was great.  It talked about maintaining existing software.

A favorite past time of most developers is to call your fellow geek over and have them check out some really smelly piece of code.  I am sure it even happens to my code from time to time, hopefully not to often.  



Friday, May 31, 2013

Remote Desktop to Hyper-V on Windows 8

So the virtual machine connection inside of hyper-v stinks.  Limited resolution choices and no copy/ past functionality.  None of the niceties of remote desktop.  As a developer a very difficult environment to work in.

So I spent some time trying to get it to work, and found this solution

https://stoknes.sharepoint.com/runesblog/Lists/Posts/Post.aspx?ID=12&mobile=0

I followed the instructions, did not change my default ip address.

Make sure you put the address in your remote desktop window as <your_virtual_machine's_name>.mshome.net


Wednesday, May 15, 2013

4 Steps to take a SQL SERVER Database out of Single User Mode

Recently my database got stuck in single user mode and I could not open it to change into multi-user.

Steps 1-4 will show you how it works.  Step 5 shows how to do it with one script

 I used the scripts below to fix this.
This is in SQL Server management studio with SQL Server R2

1. Find My Database id
    SELECT db_id('MyDB')


2. Find the session id that was using the single user mode, using the dbid returned from step 1 
    SELECT SPID,DBID,*
  FROM SYSPROCESSES
  WHERE DBID NOT IN(1,2,3,4) 

  AND SPID>50 
  AND SPID<>@@spid 
  AND dbid=[DBID]

3.Kill the session using the SPID from step 2
   KILL 999

4.put the database back into multi-user mode
   ALTER DATABASE MyDatabase
   SET MULTI_USER


Now you can get back into your database, 

       
Below is a script to do it all at once.
DECLARE @DBID AS INT
DECLARE @SPID AS INT
DECLARE @SQL AS NVARCHAR(MAX)

SELECT @SPID=SPID
FROM SYSPROCESSES
WHERE DBID NOT IN(1,2,3,4) AND SPID>50 AND SPID<>@@spid AND dbid=db_id('MyDatabase')

IF @SPID!=NULL
BEGIN
    SELECT 'Nothing to delete'
END
ELSE
BEGIN
    SET @SQL='KILL '+CONVERT(VARCHAR,@SPID)
   
    EXEC sp_executesql @SQL
END

ALTER DATABASE MyDatabase
SET MULTI_USER


To Format this TSQL I Used http://www.ubitsoft.com/products/t-sql-beautifier/ it worked great

Thursday, April 18, 2013

JQuery for a select all checkbox

So I have a asp.net repeater with a bunch of check boxes.  I want to have a select all/unselect all checckbox at the top of the repeater.

I used this little snippet of jquery to do it.

I got this great script from the bottom of a stack overflow post Here is a small revision on this, when doing this in asp.net with an ajax update panel you need to add the live. This way when the update panel refeshed the html, you can re-connect to your event.

Thursday, April 11, 2013

asp.net Update Panel and hiding elements

When working on a asp.net application that was using multiple update panels I was getting an error something like


Could not find UpdatePanel with ID 'xxx'. If it is being updated dynamically then it must be inside another UpdatePanel

I found the post below on stack overflow.


Basically my issue was that I was hiding the <asp:Panel> that contained the update panel.  This does not work at all.  You cannot do

<asp:panel visible="false" runat="server">
     <asp:UpdatePanel runat="server">
          <ContentTemplate>
                    <div>some stuff</div>
         </ContentTemplate>
    </asp:UpdatePanel>
</asp:panel>

Once I removed the visible="false" from the <asp:Panel> that my <asp:UpdatePanel> and everything worked like a charm.






Tuesday, March 12, 2013

WPF XAML App.config Transformations - Slow Cheeta

I was really tired of commenting and un-commenting out my app.config for my wpf application.  When  deploying I would forget to switch my database connection from dev to test or production.

I am now using Slow Cheeta to transform my app.config by build configuration.  Tying a build configuration to each one of my environments.  It is super easy and works great.

Tuesday, March 5, 2013

Visual Studio Keyboard Shortcut - Highlight Word Ctrl + Shift + Arrow

Sometimes when I am selecting text to cut "Ctrl+x" or paste "Ctrl+v" in visual studio I am selecting a bunch of text. This can take some time by holding the "Shift+right arrow" or "Shift+left arrow".

Recently I found a quicker way "Ctrl + Shift + Right Arrow" or "Ctrl + Shift + Left Arrow" will select a whole word.

Next time you are selecting a bunch of text try it out.  I tried this keyboard shortcut and it even works in Blogger.