Search This Blog

Monday, May 23, 2011

How to create a linked server from a local SQL server instance

I needed to add my local server as a named linked server on my development workstation.
Here is the magic hand shake...

--local linked server
EXEC sp_addlinkedserver
@server='FUSIONRIS',
@srvproduct='',
@provider='SQLNCLI',
@datasrc=''

Thursday, May 19, 2011

Resolving CAPICOM reference for .net project

The following was taken from : http://www.jensign.com/JavaScience/CapiCert/index.html

CAPICOM 2 Interop:
Much of the useful certificate store functionality of cryptoAPI has been encapsulated in CAPICOM. CAPICOM provides advanced capability, including support for pkcs7 signatures, envelopes, encryption, Authenticode signatures and advanced certificate store access. CAPICOM requires an end user component dll installation and registration, and deployment of a .net interop assembly. An interop assembly for CAPICOM can be easily built using:
tlbimp capicom.dll /namespace:CAPICOM /out:Interop.CAPICOM.dll
This is essentially the same command executed by VS.net when the COM reference is added. Note that the interop assembly has explicitly been given the namespace CAPICOM while the assembly is titledInterop.CAPICOM. The simple C# application below is compiled using:
csc /r:interop.capicom.dll FindCertnet.cs
To execute the application, the Interop.CAPICOM.dll assembly must be in the application directory, or if Strong Name signed, can be deployed to the GAC for shared access by other .net applications referencing CAPICOM. The application demonstrates basic certificate store access using CAPICOM. It also demonstrates different ways of using a Certificates enumeration, including the indexer. Casting to the ICertContext interface provides the context that can be used with X509Certificate(IntPtr handle) constructor, although with CAPICOM installed, all the functionality is available from the interop assembly. A few properties of an X509Certificate object are displayed:

Monday, May 16, 2011

Reformatted code examples

When I upgraded by site template, I forgot to re-add div class to format source code.
Code snippet I use is from http://bguide.blogspot.com/

/*
Custom CSS class to display code snippets.
http://bguide.blogspot.com/
2008 Feb 03
*/
.mycode
{
white-space:pre;
font-family:monospace;
font-size:9pt;
line-height: 10pt;
height:auto;
width:auto;
padding:5px;
margin-left:10px;
overflow:auto;
}

How to Implement a wait() in VB6

Here is how I created a Wait() for VB6.
Needed for a project to allow form code to pause while still allowing a 3rd party control to upload a file to a server.

Public Sub Wait(milliseconds As Integer)
Dim dTimer As Double
dTimer = Timer
Do While Timer dTimer + CDbl(milliseconds / 1000)
DoEvents
Loop
End Sub

Thursday, May 12, 2011

Mainstream support phases for .NET

Microsoft has published a new article about .NET 3.x support policy:

Mainstream support phases will end as follows:

.NET 2.0: 4/12/2011
.NET 3.0: 4/12/2011
.NET 3.5: 4/12/2011
.NET 3.5 SP1: 1/13/2015 (part of Windows 7)
.NET 4.0: ? at least 3/31/2015
Beginning with .NET 3.5 SP1, the .NET Framework is considered a Component of the Windows OS. Components follow the Support Lifecycle policy of their parent product or platform.

Wednesday, May 11, 2011

Determine if .net 2.0 framework service packs are installed.

To determine if a service pack is installed on a specific framework version :
- open the registry editor(regedit)
(All versions are listed to the path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\)
- Look at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\vX.X.XXXXX
(Where the X means the version to check
- Look at the key SP, the value is the service pack installed

In exemple, for the framework 2.0 
Path : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727
Key SP value : 1

This information means the Framework 2.0 sp1 is installed

Tuesday, May 10, 2011

Windows Password Reset Tool

http://pogostick.net/~pnh/ntpasswd/

  • This is a utility to reset the password of any user that has a valid (local) account on your Windows NT/2k/XP/Vista/Win7 etc system.
  • You do not need to know the old password to set a new one.
  • It works offline, that is, you have to shutdown your computer and boot off a floppydisk or CD or another system.
  • Will detect and offer to unlock locked or disabled out user accounts!
  • There is also a registry editor and other registry utilities that works under linux/unix, and can be used for other things than password editing.

Thursday, May 5, 2011

How to append to a text field in t-sql SQL Server 2005/2008

update
tablename
set
fieldname = convert(nvarchar(max),fieldname) + 'appended string'