This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Me And My Respected Teacher Mr Kamal Sheel Mishra

Mr. K.S. Mishra is HOD of Computer Science from SMS Varanasi where I have completed my MCA

Me And My Respected Teacher Mr Udayan Maiti

Mr. Udayan Maiti is a senior .Net Expert and has guided many professionals of multi national Companies(MNC)

Me And My Best Friend Mr Ravinder Goel

Mr. Ravinder Goel is a senior Software Engineer and now he is working Wipro Technology

Wednesday, 29 February 2012

Connectivity with Sql Server with ADO .Net


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace MyDataConnectivity
{
  
    public partial class Form1 : Form
    {
        SqlConnection con;
        SqlCommand cmd;
       
        public Form1()
        {
            InitializeComponent();
        }
       
        private void Form1_Load(object sender, EventArgs e)
        {
           
          
        }

        private void btn_insert_Click(object sender, EventArgs e)
        {


// Connectivity in  ADO .NET ........with Sql Parameter

try
  {
   con = new SqlConnection();
con.ConnectionString = "Data Source=KUSH-PC\\SQLSERVER2008; Initial Catalog=MyDemo; Integrated Security= SSPI";
con.Open();
cmd = new SqlCommand();
cmd.CommandText = "insert into customer_details (Customer_id,Customer_Fname,Customer_Lname,DOB,Father_Name,Mobile_No) Values('" + txtcustomerid.Text + "','" + txtcusfname.Text + "','" + txtcuslname.Text + "','" + txtcusdob.Text + "','" + txtfathername.Text + "','" + txtmobileno.Text + "')";
 cmd.Connection = con;
 cmd.ExecuteNonQuery();
 MessageBox.Show("SAVED");
                con.Close();
   }
     catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }

        
// Connectivity in  ADO .NET ....................................with Sql Parameter

            try
            {
con = new SqlConnection("Data Source=KUSH-PC\\SQLSERVER2008; Initial Catalog=MyDemo; Integrated Security= SSPI");
 con.Open();
cmd = new SqlCommand("insert into customer_detailsvalues(@Customer_id,@Customer_Fname,@Customer_Lname,@DOB,@Father_Name,@Mobile_No)", con);
       cmd.Parameters.AddWithValue("@customer_id", txtcustomerid.Text);
       cmd.Parameters.AddWithValue("@customer_fname", txtcusfname.Text);
       cmd.Parameters.AddWithValue("@customer_lname", txtcuslname.Text);
       cmd.Parameters.AddWithValue("@dob", Convert.ToDateTime(txtcusdob.Text));
       cmd.Parameters.AddWithValue("@father_name", txtfathername.Text);
       cmd.Parameters.AddWithValue("@mobile_no", txtmobileno.Text);
       cmd.ExecuteNonQuery();
       MessageBox.Show("SAVED");
       con.Close();
        }
            
catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }



//Connectivity in  ADO .NET ....................................with DataSet Table Adapter (Disconnected Mode)


try
{

 DataSet1TableAdapters.customer_detailsTableAdapter da = new DataSet1TableAdapters.customer_detailsTableAdapter();
da.Insert(txtcustomerid.Text, txtcusfname.Text, txtcuslname.Text, Convert.ToDateTime(txtcusdob.Text), txtfathername.Text, txtmobileno.Text);
MessageBox.Show("SAVED");
}
 catch (Exception ex)
  {
 MessageBox.Show(ex.Message);

  }
        




}
    


}


}


Tuesday, 28 February 2012

Check Given No Prime or Not Prime




// Program for prime no



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace primeNo
{

    public partial class Form1 : Form
    {
        int i;

        public Form1()
        {
            InitializeComponent();
        }
      private void btnprime_Click(object sender, EventArgs e)
        {
            int n = Convert.ToInt32(txtno.Text);
            if (n == 1)
            {
                MessageBox.Show(n + "is not Prime");
            }
            for (i = 2; i < n; i++)
            {
                if (n % i == 0)
                {
                    MessageBox.Show(n + "-is not Prime");
                    break;
                }
            }
            //if (i ==n)
            if (i % n == 0)
            {
                MessageBox.Show(n + "is Prime");
            }
        }

        private void btneven_Click(object sender, EventArgs e)
        {
            int n = Convert.ToInt32(txtno.Text);
            if (n == 1)
            {
                MessageBox.Show(n +     "is Odd No ");
            }
            if (n % 2 == 0)
            {
                MessageBox.Show(n +      "is Even ");

            }
            else
            {
                MessageBox.Show(n +     "is not Even ");
            }
       
        }

        private void btnodd_Click(object sender, EventArgs e)
        {
            int n = Convert.ToInt32(txtno.Text);
            if (n == 1)
            {
                MessageBox.Show(n + "is  1 ");
            }

            if (n % 2 == 0)
            {
                MessageBox.Show(n + "is Odd ");

            }
            else
            {
                MessageBox.Show(n + "is not Odd ");
            }
        }
    }
}