Skip to main content

Installing MS SQL Server 2008 in Windows 7 O.S

· One min read

INSTALL THE FOLLOWING IN ORDER for Windows 7 O.S

1. Microsoft .NET Framework 4 (Standalone Installer) - dotNetFx40_Full_x86_x64.exe http://www.microsoft.com/downloads/en/details.aspx?FamilyID=0a391abd-25c1-4fc0-919f-b21f31ab88b7&displaylang=en

2. Install SQL Server 2008 a. Throws firewall warning - Ignore it and proceed b. Don't open the sql server management studio

3. Download and instal SQLServer2008SP1 - SQLServer2008SP1-KB968369-x64-ENU.exe http://www.microsoft.com/downloads/en/details.aspx?FamilyID=66ab3dbb-bf3e-4f46-9559-ccc6a4f9dc19&displaylang=en

4. Download and install SQLServer2008SP2 - SQLServer2008SP2-KB2285068-x64-ENU.exe http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8fbfc1de-d25e-4790-88b5-7dda1f1d4e17

Code Snippets in VS2008 for C

· 5 min read

Usage

Enter snippet Keyword shown below and press TAB-TAB to expand the snippet

Snippet KeywordExpanded Snippet
#ifCode snippet for #if
#regionCode snippet for #region
attributeCode snippet for attribute using recommended pattern
checkedCode snippet for checked block
classCode snippet for class
ctorCode snippet for constructor
~Code snippet for destructor
cwCode snippet for Console.WriteLine
doCode snippet for do…while loop
elseCode snippet for else statement
enumCode snippet for enum
equalsCode snippet for implementing Equals() according to guidelines
exceptionCode snippet for exception
forCode snippet for ‘for’ loop
foreachCode snippet for foreach statement
forrCode snippet for reverse ‘for’ loop
ifCode snippet for if statement
indexerCode snippet for indexer
interfaceCode snippet for interface
invokeCode snippet for safely invoking an event
iteratorCode snippet for a simple iterator
iterindexCode snippet for ‘named’ iterator/indexer pair using a nested class
lockCode snippet for lock statement
mboxCode snippet for MessageBox.Show
namespaceCode snippet for namespace
propCode snippet for an automatically implemented property
propgCode snippet for an automatically implemented property with a ‘get’ access or/and a private ‘set’ accessor
simCode snippet for int Main()
structCode snippet for struct
svmCode snippet for ‘void Main’ method
switchCode snippet for switch statement
tryCode snippet for try catch
tryfCode snippet for try finally
uncheckedCode snippet for unchecked block
unsafeCode snippet for unsafe statement
usingCode snippet for using statement
whileCode snippet for while loop

WCF Step by Step Tutorial

· One min read

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF we can build secure, reliable, transacted solutions that integrate across platforms.

WCF is a unified framework which provides :

  1. NET Remoting
  2. Distributed Transactions
  3. Message Queues and
  4. Web Services into a single service-oriented programming model for distributed computing.

Read more

Converting from CString

· 2 min read

This post demonstrates how to convert from a CString to the other string types

CString to LPTSTR

CString origCString = "HelloWorld";

// Get the internal buffer pointer of CString.
LPTSTR pString = origCString.GetBuffer(0);

//Release it.
origCString.ReleaseBuffer();

LPTSTR to CString

LPTSTR origLPTSTR = "HelloWorld";
CString sCString = CString(origLPTSTR);

CString to char*

CString origCString = "HelloWorld";

// Get the internal buffer pointer of CString.
char* pString = origCString.GetBuffer();

//Release it.
origCString.ReleaseBuffer();

char to* CString

char* origchar = "HelloWorld";
CString cstring = CString(origchar);

CString to CComBSTR

CString origCString = "HelloWorld";
CComBSTR ccombstr = CComBSTR(origCString);

CComBSTR to CString

CComBSTR origCComBSTR = "HelloWorld";
CString cstring = CString(origCComBSTR);

CString to _bstr_t

CString origCString = "HelloWorld";
_bstr_t bstrt = _bstr_t(origCString);

_bstr_t to CString

_bstr_t origbstrt  = "HelloWorld";
CString cstring = CString((char\*)origbstrt);

CString to BSTR

CString origCString = "HelloWorld";
BSTR bstr = origCString.AllocSysString();
::SysFreeString(bstr); //Free the string.

BSTR to CString

BSTR origbstr  = "HelloWorld";
CString cstring = CString(origbstr);

CString to CComVariant

CString origCString = "HelloWorld";
CComVariant comvariant = CComVariant(origCString);

CComVariant to CString

CComVariant origcomvariant  = "HelloWorld";
CString cstring = CString(origcomvariant);

CString to COleVariant

CString origCString = "HelloWorld";
COleVariant olevariant = CComVariant(origCString);

COleVariant to CString

COleVariant origolevariant  = "HelloWorld";
CString cstring = CString(origolevariant);

C FAQ 4 to 7: Simple Programs

· One min read

4. Swap of two numbers  with out temp

#include "stdio.h";

int main()
{
int a,b;
a=10;
b=20;
printf("Before swapingn");
printf("%dt%dn",a,b);

/* normal temp
int temp;
temp=a;
a=b;
b=temp;

//sol:-1
a=a+b;
b=a-b;
a=a-b;

//sol:-2
a=ab;
b=a/b;
a=a/b;/

//sol:-3
//a^=b^=a^=b;

a= a^b;
b= a^b;
a= a^b;
printf("%dt",a);
printf("After swapingn");
printf("%dt%dn",a,b);
return 0;
}

Read More

Tags:

Write a code to Outputs its own code

· One min read

FILE macro is a Predefined Macros : The name of the current source file. FILE expands to a string surrounded by double quotation marks.

fgetc: Read a character from a stream. returns an integer putchar: Writes a character to a stream

# include "stdio.h"
//Program that outputs its own code

int main () {
FILE *fp; char c;
fp = fopen(__FILE__,"r");

while((c=getc(fp))!= EOF) {
printf("%c",c);
}
fclose(fp);
}
Tags:

Design Pattern: C# Singleton

· One min read
using System;

namespace CSharp {
//Singleton: Ensure a class only has one instance,
//and provide a global point of access to it.
class Singleton {
//Member Variable
private static Singleton instance = null;

//Member Functions
private Singleton()
{
}

public static Singleton Instance()
{
if(instance == null )
{
instance = new Singleton ();
}

return instance;
}

public void print()
{
Console.WriteLine("Singleton Class" );
}

};

class Program {

static void Main(string[] args) {
Singleton n = Singleton .Instance();
n.print();
Singleton p = Singleton .Instance();
p.print();
}

}

}

Restore a Database Backup in MS SQL Server 2008

· One min read

How to Restore a Database Backup Using .bak file in MS SQL Server 2008

.bak files are database backups we can restore the Database backup using SQL Server Management Studio.

A. Open SQL Server Management Studio in Object Explorer Right Click on 'Databases' Node and select 'Restore Database'

B. 'Restore Database' Dialog will be displayed on the General page

  1. The name of the restoring database appears in the To database list box. To create a new database, enter its name in the list box.

  2. Select 'From device'

  3. Click button to display 'Specify Backup' Dialog

  4. Click 'Add'  to browse the .bak file from the directory and click OK

Change the name of the Debug Version of a DLL or Exe

· One min read

Its very useful to name the Debug version of the exe or DLL with letter "D" appended in-order to avoid confusion between release and debug version of binaries

Steps:

  1. Create a console application with name "MyProject"

  2. To change the output file name in debug configuration

place D as shown in below figure

Project Project Properties -> Linker -> General -> Output File

Release Version: MyProject Application Name: c:MyProjectReleaseMyProject.exe Debug Version: MyProject Application Name: c:MyProjectDebugMyProjectD.exe