Random scripts

By admin - Last updated: Sunday, March 7, 2010 - Save & Share - Leave a Comment

SQL transaction try catch template

BEGIN TRY
BEGIN TRAN
– sql goes here
COMMIT
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage
ROLLBACK
END CATCH

Very nice blog around WCF security

http://www.leastprivilege.com

Search object name within SQL database

SELECT name FROM sysobjects
WHERE id IN
( SELECT id FROM syscolumns WHERE name = ‘keyword’ )

Close remote desktop session on remote server

>qwinsta /server:server_ip_here
>rwinsta /server:server_ip_here id_here

Some Syntax

sync
[MethodImpl(MethodImplOptions.Synchronized)]
public void HelloWorld(){}

lambda
Console.CancelKeyPress += (sender, e) => { Console.WriteLine(“CTRL+C detected!\n”); e.Cancel = true;};

anonymous type
void Do()
{
Foo(new {Name=”wall-e”, Age=999}, new {Name=default(string), Age=default(int)});
}

T Foo(object obj, T type)
{
return (T) obj;
}

anonymous type infer property name
string a = “this is a”;
string b= “this is b”;
var obj = {a, b};
Console.WriteLine(obj.a);
Console.WriteLine(obj.b);

without calling any finally blocks or finalizers
Environment.FailFast()

deriving class must contain parameterless constructor
public interface MyClass where T : MyClass , new()

using different version of class

extern alias oldVer;
extern alias newVer;
using System;
csc /r:oldVer=Somepath\ClassLibrary.dll /r:newVer=AnotherPath\ClassLibrary.dll program.cs

Environment.UserInteractive is false when no UI for the app.

Empty sln file of 2008 content

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

WCF where are all the namespaces defined in WSDL

wsdl:definitions      [ServiceBehavior]
wsdl:portType       [ServiceContract]
wsdl:part>            [MessageContract]
xs:schema            [DataContract] 	[MessageContract] 	[MessageBodyMember]
binding                 bindingNamespace on endpoint



Posted in Random • • Top Of Page

Write a comment


Captcha: 9 − four =