Wednesday, November 09, 2011 #

SQL Server-Determine which query is taking a long time to complete

 

Cool little trick to determine which sql query which is taking a long time to execute, first while offending query is running from another machine do

EXEC sp_who2

Locate the SPID responsible via Login, DBName and ProgramName columns, then do

DBCC INPUTBUFFER (<SPID>)

The offending query will be in the EventInfo column.  This is a great little time saver for me, before I found out about this I used to split my concatenated query script in to multiple sql files until I located the problem query

Posted On Wednesday, November 09, 2011 4:30 PM | Feedback (0)

Friday, April 29, 2011 #

Umbraco 4.0.x.x UComment 1.0

If you have a web site using Umbraco and you wish to add the ability to comment on submitted articles then UComment is a quite brilliant little package, the functionality can be added in no time at all.  My problem was that the web site in question uses Umbraco 4.0.x.x and I couldn’t upgrade to the most recent (4.7 at the time of writing) due to not being able to back up the database before I begin (shared web hosting).

This meant I was forced in to using UComment 1.0 because 1.1 is tied to Umbraco 4.5 and 1.2 is tied to Umbraco 4.7 etc.. so I downloaded the 1.0 Umbraco package and installed it.  Unfortunately there are bugs in UComment 1.0 to do with page validation and the forcing of the user to enter a web site address before they can post anything.  The comment form would not pass validation checks for .co.uk, .org, .org.uk and lots of other possible domains.  I have modified the UComment 1.0 c# source code to fix these issues, and compiled the UComment.dll assembly for .net 3.5, the project can be downloaded from here.

Might save someone somewhere some work Smile

Posted On Friday, April 29, 2011 11:59 AM | Feedback (0)

Wednesday, March 03, 2010 #

Sql Server search stored procs for text

Search all stored procedures in a database for a string

SELECT routine_name, routine_definition 

FROM information_schema.routines

WHERE routine_definition LIKE '%textyoursearchingfor%'

AND routine_type = 'PROCEDURE'

Posted On Wednesday, March 03, 2010 4:55 PM | Feedback (0)

Thursday, June 18, 2009 #

MCTS 70-536 Exam

Three months of hard work paid off today and I scored 982 out of 1000, would love to know on which question I lost those 18 points…

Posted On Thursday, June 18, 2009 7:14 AM | Feedback (3)

Saturday, March 07, 2009 #

Regular VS IDE Colour Scheme Changes Improve Productivity..

.. maybe / maybe not.  I've collected / created lots of colour scheme .vssettings xml files over the years, here are some of my favourites... enjoy!

All files are guaranteed to only contain settings for the All Settings->Options->Environment->Fonts and Colours so the rest of your visual studio settings remain untouched.  All files are in VS2008 format though they can be edited to work with VS2005 by editing the line :-

<ApplicationIdentity version="9.0" />

to read

<ApplicationIdentity version="8.0" />

Posted On Saturday, March 07, 2009 1:47 AM | Feedback (1)

Friday, November 14, 2008 #

Agent Ransack

Just discovered this great piece of free software from mythicsoft, it is a cut down version of a product called File Locator Pro. It is clearly aimed at software developers and is great for finding files which contain certain strings / lines of code.  Prior to finding this program I had been using source code modified from http://www.codeproject.com/KB/cs/fulltextsearchingifinters.aspx to suit my needs, the results are good but not as good as agent ransack, give it a try :-

http://www.mythicsoft.com/agentransack/download.aspx

Great new look to the site btw

Posted On Friday, November 14, 2008 4:01 AM | Feedback (0)

Thursday, July 10, 2008 #

Directory.GetFiles() in Modified Date/Time Order Pt2

Following on from this.  I've noticed that it only gives you to the second accuracy.  If your software is capable of making more than one file per second, the sort order will be date/time to the second then alphanumerically on the filename.  Not ideal if your filenames are guids, the following class gives date/time sort accuracy of 100 nanosecond intervals then alphanumerically on filename :-

   1:  Imports System.IO
   2:  Imports System.Runtime.InteropServices
   3:  Imports System.Runtime.InteropServices.ComTypes
   4:  Imports Microsoft.Win32.SafeHandles
   5:  Imports Microsoft.Win32
   6:  Public Class clsCompareFileInfo
   7:      Implements IComparer
   8:   
   9:      Private Const GENERIC_READ = &H80000000
  10:      Private Const OPEN_EXISTING = 3
  11:      Private Const FILE_SHARE_READ = &H1
  12:      Private Const FILE_SHARE_WRITE = &H2
  13:      Private Const FILE_ATTRIBUTE_NORMAL = &H80
  14:      Private Const FILE_FLAG_NO_BUFFERING = &H20000000
  15:   
  16:      Public Structure FILETIME
  17:          Public dwLowDateTime As Long
  18:          Public dwHighDateTime As Long
  19:      End Structure
  20:   
  21:      Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Integer, ByRef lpCreationTime As ComTypes.FILETIME, ByRef lpLastAccessTime As ComTypes.FILETIME, ByRef lpLastWriteTime As ComTypes.FILETIME) As Integer
  22:   
  23:      Private Declare Auto Function CreateFile Lib "kernel32.dll" (ByVal lpFileName As String, _
  24:  ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, _
  25:  ByVal lpSecurityAttributes As IntPtr, ByVal dwCreationDisposition As Integer, _
  26:  ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As IntPtr) As IntPtr
  27:   
  28:      Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  29:      <DllImport( _
  30:                  "kernel32.dll", _
  31:                  CharSet:=CharSet.Auto, _
  32:                  SetLastError:=True)> _
  33:              Friend Shared Function CompareFileTime( _
  34:              ByRef lpFileTime1 As ComTypes.FILETIME, _
  35:              ByRef lpFileTime2 As ComTypes.FILETIME) _
  36:              As Integer
  37:      End Function
  38:   
  39:      Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
  40:          Dim File1 As FileInfo
  41:          Dim File2 As FileInfo
  42:   
  43:          File1 = DirectCast(x, FileInfo)
  44:          File2 = DirectCast(y, FileInfo)
  45:   
  46:          Dim x_Created As ComTypes.FILETIME
  47:          Dim x_Modified As ComTypes.FILETIME
  48:          Dim x_Accessed As ComTypes.FILETIME
  49:          Dim y_Created As ComTypes.FILETIME
  50:          Dim y_Modified As ComTypes.FILETIME
  51:          Dim y_Accessed As ComTypes.FILETIME
  52:   
  53:          Dim fhandle As IntPtr = CreateFile(File1.FullName, GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero)
  54:          GetFileTime(fhandle, x_Created, x_Accessed, x_Modified)
  55:   
  56:          Dim fhandle2 As IntPtr = CreateFile(File2.FullName, GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero)
  57:          GetFileTime(fhandle2, y_Created, y_Accessed, y_Modified)
  58:   
  59:          CloseHandle(fhandle)
  60:          CloseHandle(fhandle2)
  61:   
  62:          Compare = CompareFileTime(x_Modified, y_Modified)
  63:      End Function
  64:  End Class

Posted On Thursday, July 10, 2008 9:19 PM | Feedback (1)

Thursday, April 17, 2008 #

SBS2003, ISA Server & 550 FTP errors

Given the time (nearly 2 days!) it's taken me to get to the bottom of this I thought it worthy of a blog post hopefully saving someone the hours of frustration i've just been through.  I know my FTP code works very well, around 50 different customer sites with very few support calls confirm this, on this one installation however my xml documents would not arrive at the web server.  My logging code confirmed that we were connecting to the server ok, successfully managing to cwd to the appropriate directory yet sending the file would fail with a 550 error code, same results from the server and any machine on the domain. 

My customers hardware supplier assured me they'd adjusted the firewall to allow ftp and it must be my codes fault, not so, after dialling in to the server and looking at the firewall rules within isa management console, you can right click the firewall rules, choose configure and a dialog will appear with a solitary check box "Read only" which defaults to ticked when adding ftp rules, un-tick that, restart and it all worked.

Their hardware company had convinced me it must be my code, I ended up installing visual studio on one of their machines to step through my code convinced it must be a bug.  Not happy when I found out my code was fine and i'd been pulling my hair out because of their incompetence, anyway, I hope this helps someone out...

Posted On Thursday, April 17, 2008 6:49 AM | Feedback (2)

Thursday, March 13, 2008 #

Sh!teware

A pet hate of mine (one of many :-j) is bloated software, especially device drivers you know the sort of thing installing a printer requiring hundreds of mb disk space and adding system tray applets (HP?), I collectively refer to this stuff as shiteware something needs to be done, it's getting worse.

 

This (http://www.physorg.com/news124646014.html) sort of thing was inevitable, of course it's easy to sort out but it's just becoming such a pain time wise.  Laws need to be put in place and people need to be made accountable (strung up and tortured). </rant>

Posted On Thursday, March 13, 2008 9:57 PM | Feedback (0)

Tuesday, February 26, 2008 #

Happy birthday...

Today marks the second birthday of my xbox 360 and it's still going strong.  Since day one it's stood vertically and hasn't been moved an inch.  In these days of rrod ridden horror stories I thought i'd share...

Posted On Tuesday, February 26, 2008 1:36 PM | Feedback (0)

Sunday, January 13, 2008 #

USB3

USB 3

http://www.reghardware.co.uk/2008/01/09/ces_usb_3_revealed/

Posted On Sunday, January 13, 2008 2:42 PM | Feedback (1)

Friday, January 04, 2008 #

UserControl actually has OnTextChanged event

 Wow, didn't know that adding

[Browsable(true), EditorBrowsable(EditorBrowsableState.Always)]
new public event EventHandler TextChanged
{
add {base.TextChanged += value;}
remove {base.TextChanged -= value;}
}

and

private void txtbox1_TextChanged(object sender, EventArgs e)
{base.OnTextChanged(e);}

Actually gives a textbox based usercontrol a TextChanged event at design time, much nicer than other methods i've used previously.

Posted On Friday, January 04, 2008 4:19 PM | Feedback (3)

Wednesday, October 24, 2007 #

Cubase 4.1 is here!

and its good, knocked this up quickly to play with new sidechaining and other features

http://www.herefordsoftwaresolutions.co.uk/Rightism.mp3

Posted On Wednesday, October 24, 2007 7:06 AM | Feedback (1)

Wednesday, July 18, 2007 #

Been a while :-)

Hi there, been a while since posting though I do read GWB most days.  Involved in a number of new projects and looking to get back into my blogging.  Got an ancient vb6 app with lots of datagrids bound to adodc controls and need to add mousewheel support, customers are moaning that it doesn't support mouse wheels, the fact that vb6 pre dates mouse wheels doesn't wash.. anyway, someone might find it useful so here it is :-

Private Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Public Const MK_CONTROL = &H8
Public Const MK_LBUTTON = &H1
Public Const MK_RBUTTON = &H2
Public Const MK_MBUTTON = &H10
Public Const MK_SHIFT = &H4
Private Const GWL_WNDPROC = -4
Private Const WM_MOUSEWHEEL = &H20A

Dim LocalHwnd As Long
Dim LocalPrevWndProc As Long
Dim MyForm As Form

 

Private Sub Form_Activate()
WheelHook Me
End Sub

Private Sub Form_Deactivate()
WheelUnHook
End Sub

 

Private Function WindowProc(ByVal Lwnd As Long, ByVal Lmsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim MouseKeys As Long, Rotation As Long, Xpos As Long, Ypos As Long
   
   If Lmsg = WM_MOUSEWHEEL Then
       MouseKeys = wParam And 65535
       Rotation = wParam / 65536
       Xpos = lParam And 65535
       Ypos = lParam / 65536
       MyForm.MouseWheel MouseKeys, Rotation, Xpos, Ypos
   End If
   WindowProc = CallWindowProc(LocalPrevWndProc, Lwnd, Lmsg, wParam, lParam)
End Function

Public Sub WheelHook(PassedForm As Form)

    On Error Resume Next
        Set MyForm = PassedForm
        LocalHwnd = PassedForm.hWnd
        LocalPrevWndProc = SetWindowLong(LocalHwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub


Public Sub WheelUnHook()
    Dim WorkFlag As Long

    On Error Resume Next
        WorkFlag = SetWindowLong(LocalHwnd, GWL_WNDPROC, LocalPrevWndProc)
        Set MyForm = Nothing
End Sub


Public Sub MouseWheel(ByVal MouseKeys As Long, ByVal Rotation As Long, ByVal Xpos As Long, ByVal Ypos As Long)
    Dim NewValue As Long
    Dim ipToAdd As Integer
    On Error Resume Next

    If Rotation > 0 Then
        ipToAdd = -3
    Else
        ipToAdd = 3
    End If
   
    If DATAGRID_Customers(0).Visible Then
        ADODC_CustbyName.RecordSet.Bookmark = adoCustbyName.RecordSet.Bookmark + ipToAdd
    ElseIf lstCustomers(1).Visible Then
        ADODC_CustbyCode.RecordSet.Bookmark = adoCustbyCode.RecordSet.Bookmark + ipToAdd
    End If
End Sub

I know, i'm guilty of using my blog as a code repository so I don't forget stuff, more modern and interesting stuff will follow!

Posted On Wednesday, July 18, 2007 6:56 AM | Feedback (0)

Thursday, December 21, 2006 #

Windows Vista Service Hardening

Windows Services can no longer read mapped network drive letters, ie Directory.Exists(“H:\XMLDOCS”) will always return false even if you have H mapped.  The solution is to run the service under a user account with access to that share in Control Panel\Administrative Tools\Services.  Then in your code access the resource using its UNC name :-Directory.Exists(“\\testsrvr01\xmldocs”).

Posted On Thursday, December 21, 2006 8:26 AM | Feedback (0)

Copyright © Neil Smith

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski