Saturday, September 5, 2009

How to reset MS SQL Server IDENTITY

If the table is new create you can use this to reset the identity
DBCC CHECKIDENT (yourtable, reseed, seed_value)

If you delete that data in the table u can use
DBCC CHECKIDENT (yourtable, reseed, 0)

Thursday, August 27, 2009

How to Install/UnInstall COM Componets

If the COM file is a executive .exe file.Excute the file with a argument as below:
 -Service            // Install .exe COM file as a windows service.
 -UnregServer    // Uninstall .exe COM componet.
 -RegServer       // Install .exe COM file as a windows COM componet.


If the COM file is a DLL file, suppose the file name is mycom.dll.
regsvr32 mycom.dll              // To install dll COM
regsvr32 /u mycom.dll          // Run regsvr32 with argument /u to uninstall the dll COM

dcomcnfg    // This tool can see the all DCOM componets has installed in the system.


The Installutil.exe is a tool for .NET componets registration
Here some argument options
Option Description
/h[elp] Displays command syntax and options for the tool.
/help assemblypath Displays any additional options recognized by individual installers within the specified assembly.
/logFile=[filename] Specifies the name of the log file where install progress is recorded. The default is assemblyname.InstallLog.
/logToConsole={true|false} If true, displays output to the console. If false (the default), suppresses output to the console.
/showCallStack Prints the call stack to the log if an exception occurs at any point during installation.
/u[ninstall] Uninstalls an assembly. Unlike other options, /u applies to all assemblies regardless of where it appears on the command line.
/? assemblypath Displays any additional options recognized by individual installers within the specified assembly.
/? Displays command syntax and options for the tool.

The SC.exe is a Windows SDK tool
The SC.exe can be used to Query, Install, Uninstall and Setting Windows Service and Windows Hardware Drivers.

How to use it go ask google!


Friday, July 17, 2009

How to config network in Solaris 10

Changes Static IP Address and Host Name
    The sample below shows how to uses ipconfig change static IP address to 192.168.0.10 with netmask 255.255.255.0
  1. ifconfig vfe0 unplumb
  2. ifconfig vfe0 plumb 192.168.0.10 netmask 255.255.255.0 up
Config host name for ethernet card
    /etc/hostname.vfe0
     solaris10
Config network mapping for IP address and host name (hostname of Ethernet card)
    the hosts file format of each line is:
        IP-address    official-host-name    nicknames....
    the nicknames can be optional.
    /etc/hosts
     127.0.0.1         localhost            loghost
     192.168.0.xxx  solaris10
    /etc/netmasks
     192.168.0.xxx 255.255.255.0
Config Gateway
    /etc/defaultrouter
     192.168.0.1
Config DNS
    1. Specify DNS Server
        /etc/resolv.conf
         nameserver 168.95.192.1
         nameserver 168.95.192.2
    2. In order to enable DNS resolve, change the line in nsswitch.conf as below
        /etc/nsswitch.conf
         hosts: files dns
         inodes: files dns

Tuesday, July 7, 2009

How to uses callback function for C++

 
// This is a callback function sample without parameter.
void callbackProc1()
{
    printf("this is a call back 1..\r\n");
}
 
// This is a callback function sample with 2 parameters
bool callbackProc2(int nSize, char* pszName) {
    printf("this is a call back 2..\r\nSize is:%d  pszName is:%s \r\n", nSize, pszName);
    return true;
}
 
// This function invoke callback function as a parameter to it
void test1(void(*p)(void))
{
    p();
}
// This function invoke a callback function with 2 parameters
void test2(bool(*p)(int, char*), int param1, char* param2)
{
    if(p(param1, param2))
    {
        printf("the callback func return TRUE.......\r\n");
    }
}

void main()
{
    // this is a sample to demonstrate how to invoke a callback function without parameter
    // the callback function name is a memory address reference to callback function.
    test1(callbackProc1);
   
    // this is a sample shows how to invoke a callback functions with two parameters
    test2(callbackProc2, 999, "johnrock");
 
 

How to create a process to run a dos command with dos dialog window

CreateProcess(NULL, "cmd /c copy file1 file2", ....),

Create Sequence Numbers for Oracle

Full Create Sequence Syntax
CREATE SEQUENCE <sequence_name> INCREMENT BY <integer> START WITH <integer> MAXVALUE <integer> / NOMAXVALUEMINVALUE <integer> / NOMINVALUECYCLE / NOCYCLECACHE <#> / NOCACHEORDER / NOORDER;

Create Sequence Simplest Form
CREATE SEQUENCE seq_campus_site_id;
SELECT seq_campus_site_id.NEXTVAL FROM dual;

Simple Autonumber With Sequence
INSERT INTO <table_name>(<column_name>)VALUES(<sequence_name>.NEXTVAL);
INSERT INTO campus_site(site_id, organization_name, campus_name)VALUES(seq_campus_site_id.NEXTVAL, 'Univ. of Washington', 'Main Seattle');
SELECT * FROM campus_site;
INSERT INTO campus_site(site_id, organization_name, campus_name)VALUES(seq_campus_site_id.NEXTVAL, 'Univ. of Washington', 'Bothell');
SELECT * FROM campus_site;

Simple Autonumber With Sequence Into Two Tables
INSERT INTO <table_name>(<column_name>)VALUES(<sequence_name>.CURRVAL);
CREATE SEQUENCE seq_division_id;
INSERT INTO campus_site(site_id, organization_name, campus_name)VALUES(seq_campus_site_id.NEXTVAL, 'Univ. of Washington', 'Tacoma');
INSERT INTO division (division_id, site_id, division_name) VALUES(seq_division_id.NEXTVAL, seq_campus_site_id.CURRVAL, 'Engineering');
SELECT * FROM campus_site;
SELECT * FROM division;

Windows Smart Card Utilities

Connect to network by smart card
net use /smartcard
Specifies the network connection is to use the credentials on a smart card. If multiple smart cards are available, you are asked to specify the credential. This parameter cannot be used with /savecred.
 
Query all available samrt card and reader in the system
certutil -scinfo
 
 
Smart card PIN tool
pintool