Monday, 5 March 2018

Connected and disconnected architecture in C#

Connected and Disconnected architecture in C#

Connected Architecture of ADO.NET
The architecture of ADO.net, in which connection must be opened to access the data retrieved from database is called as connected architecture. Connected architecture was built on the classes connection, command, datareader and transaction. 
Connected architecture is when you constantly make trips to the database for any CRUD (Create, Read, Update and Delete) operation you wish to do. This creates more traffic to the database but is normally much faster as you should be doing smaller transactions.
Disconnected Architecture in ADO.NET

The architecture of ADO.net in which data retrieved from database can be accessed even when connection to database was closed is called as disconnected architecture. Disconnected architecture of ADO.net was built on classes connection, dataadapter, commandbuilder and dataset and dataview.
Disconnected architecture is a method of retrieving a record set from the database and storing it giving you the ability to do many CRUD (Create, Read, Update and Delete) operations on the data in memory, then it can be re-synchronized with the database when reconnecting. A method of using disconnected architecture is using a Dataset.

DataReader is Connected Architecture since it keeps the connection open until all rows are fetched one by one
DataSet is DisConnected Architecture since all the records are brought at once and there is no need to keep the connection alive
Difference between Connected and disconnected architecture

Connected Disconnected
It is connection oriented.
It is dis_connection oriented.
Datareader DataSet
Connected methods gives faster performance
Disconnected get low in speed and performance.
connected can hold the data of single table disconnected can hold multiple tables of data
connected you need to use a read only forward only data reader
disconnected you cannot
Data Reader can't persist the data
Data Set can persist the data
It is Read only, we can't update the data.
We can update data

Create crystal report step by step in c-sharp

The following is the hyperlink to create the crystal report step by step in c#:
Step by step to create crystal report in c#

Sections

Sections are the design areas which you use to build your report.
Crystal Reports by default provides five main sections:

  • Report Header – fields placed in this section are printed once, at the beginning of the report
  • Page Header - fields placed in this section are printed at the beginning of each new page
  • Details – fields in this section are printed with each new record
  • Report Footer - fields placed in this section are printed once, at the end of the report
  • Page Footer - fields placed in this section are printed at the bottom of each new page

Saturday, 15 October 2016

Program to calculate payroll analysis of employees

//Program to calculate payroll analysis of employees
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct employee
{
    int id,sal;
    char nm[20],dept[20];
};
void main()
{
    struct employee e;
    float ta,da,hra,pf,net;
    clrscr();
    printf("\nEnter the details of Employee:");
    printf("\nEnter ID: ");
    scanf("%d",&e.id);
    printf("Enter Name: ");
    scanf("%s",e.nm);
    printf("Enter Department: ");
    scanf("%s",e.dept);
    printf("Enter Salary: ");
    scanf("%d",&e.sal);
    ta=e.sal*1.10;
    da=e.sal*0.55;
    hra=e.sal*0.25;
    pf=e.sal*0.10;
    net=e.sal+ta+da+hra-pf;
    printf("\n**** Employee Payroll ****\n");
    printf("ID\tName\tDept\tSalary\tTA\tDA\tHRA\tPF\tNET");
    printf("\n%d\t%s\t%s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f",e.id,e.nm,e.dept,e.sal,ta,da,hra,pf,net);
    getch();
}

Program of result using array of structure

//Program of result using array of structure
#include<stdio.h>
#include<conio.h>
struct result
{
    int no,m1,m2,m3;
    char nm[20];
    char res[6],gr[15];
};
void main()
{
    struct result r[10];
    int total[10],n,i;
    float per[10];
    clrscr();
    printf("\nEnter no of students: ");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("\n**** Enter the details of Student %d",i+1);
        printf("\nEnter no: ");
        scanf("%d",&r[i].no);
        printf("Enter name: ");
        scanf("%s",r[i].nm);
        printf("Enter Marks 1: ");
        scanf("%d",&r[i].m1);
        printf("Enter Marks 2: ");
        scanf("%d",&r[i].m2);
        printf("Enter Marks 3: ");
        scanf("%d",&r[i].m3);
    }
    for(i=0;i<n;i++)
    {
        total[i]=r[i].m1+r[i].m2+r[i].m3;
        if(r[i].m1>=40 && r[i].m2>=40 && r[i].m3>40)
        {
            strcpy(r[i].res,"Pass");
            per[i]=total[i]/3;
            if(per[i]>=70)
            {
                strcpy(r[i].gr,"Dist");
            }
            else if(per[i]>=60)
            {
                strcpy(r[i].gr,"First");
            }
            else if(per[i]>=48)
            {
                strcpy(r[i].gr,"Second");
            }
            else if(per[i]>=40)
            {
                strcpy(r[i].gr,"Pass");
            }
        }
        else
        {
            strcpy(r[i].res,"Fail");
            per[i]=0.00;
            strcpy(r[i].gr," ******** ");
        }
    }
    printf("\n **** Result **** \n");
    printf("\nNo\tName\tM1\tM2\tM3\tTotal\tPer\tResult\tGrade");
    for(i=0;i<n;i++)
    {
        printf("\n%d\t%s\t%d\t%d\t%d\t%d\t%f\t%s\t%s",r[i].no,r[i].nm,r[i].m1,r[i].m2,r[i].m3,total[i],per[i],r[i].res,r[i].gr);
    }
    getch();
}

Monday, 10 October 2016

Program to edit the record of student database

set talk off
clear
use stude
do while .T.
    clear
    store 0 to rno
    store space(15) to nm
    store space(15) to ct
    store space(1) to gn,opt
    store {} to dt
    @5,5 say "Enter roll no: " get rno pict "999" valid rno>0 error "Roll no >0"
    read
    seek rno
    if not found()
        wait window "Roll no not found"
        loop
    endif
    rno=rollno
    nm=name
    ct=city
    dt=dob
    gn=gender
    @2,2 to 23,80 double
    @5,30 say "Student Data Entry" font "Cambria",16
    @8,3 say repl("=",77)
    @10,10 say "Enter roll no: " get rno pict "999" valid rno>0 error "Roll no should be greater than zero"
    @12,10 say "Enter name: "get nm pict "@!"
    @14,10 say "Enter city: "get ct pict "@!"
    @16,10 say "Enter DOB: " get dt function "E"
    @18,10 say "Enter gender: "get gn pict "!" valid gn="M" or gn="F" error "Gender must be M or F"
    @20,3 say repl("=",77)
    @21,20 say "Do you want to edit more record?" get opt func "!" pict "Y"
    read
 
    replace rollno with rno
    replace name with nm
    replace city with ct
    replace dob with dt
    replace gender with gn
    if opt="N " then
        exit
    endif
enddo
    use
    clear all
set talk on

Program to insert the record in foxpro

 Create a table Stude
rollno               number          5
name              character      15
city                 character      15
gender            characer          1
dob                 date
set talk off
clear
use stude
do while .T.
    clear
    store 0 to rno
    store space(15) to nm
    store space(15) to ct
    store space(1) to gn,opt
    store {} to dt
    @2,2 to 23,80 double
    @5,30 say "Student Data Entry" font "Cambria",16
    @8,3 say repl("=",77)
    @10,10 say "Enter roll no: " get rno pict "999" valid rno>0 error "Roll no should be greater than zero"
    @12,10 say "Enter name: "get nm pict "@!"
    @14,10 say "Enter city: "get ct pict "@!"
    @16,10 say "Enter DOB: " get dt function "E"
    @18,10 say "Enter gender: "get gn pict "!" valid gn="M" or gn="F" error "Gender must be M or F"
    @20,3 say repl("=",77)
    @21,20 say "Do you want to add more record?" get opt func "!" pict "Y"
    read
    append blank
    replace rollno with rno
    replace name with nm
    replace city with ct
    replace dob with dt
    replace gender with gn
    if opt="N " then
        exit
    endif
enddo
    use
    clear all
set talk on
   
   

Tuesday, 4 October 2016

To generate Fibonacci Series using recursion

#include<stdio.h>
#include<conio.h>
void main()
{
            int n,i,x,fibo(int);
            clrscr();
            printf("\n\n Enter the number of elements:");
            scanf("%d",&n);
            printf("\n\n The fibonacci series is:");
            for(i=0; i<n+1; i++)
            {
                        printf("\n%d",fibo(i));
            }
            getch();
}
int fibo(int a)
{
            if(a==0)
               {
                                  return(0);
              }
            else if(a==1)
            {
                                      return(1);
             }
            else 
             {
                                   return(fibo(a-1)+fibo(a-2));
             }
}