Friday, 28 June 2013

Why we used ref keyword ?

Suppose you have to get the value that has changed inside function. to get that changed value outside the function then use ref keyword.

1. This should be used when you re-instantiate the object inside function. 

2. This should be used, if your object is string or any value type Object.

Class1 ObjClass = new Class1();
ObjClass.StrA = 55;
GetA(ref ObjClass);
int ss = ObjClass.StrA; //ss value is 99 after re-instatiate inside function

private void GetA(Class1 ObjClass)
{
   ObjClass = new Class1();
   ObjClass.StrA = 99;
}

Thursday, 27 June 2013

Do Audit Trail by triggers in MS-SQL

I have written SQL dynamic script which will create tirggers in your database. you have to just mention table name.
if your audit log table column would different then do some customization in query as per your requirement.

columns of audit log table

 mode        -     Insert/Update  
 insertedon    -     Current date  
 tblname      -    Table Name       
 colname      -    Coulumn Name  
 id           -    Primary Key Of Table  
 oldval        -    Old Value before update  
 newval       -    New Value after Update or Insert  
 Ip          -    Ip Address of table  


Donwload Audit Trail txt