Monday 1 April 2013

ExecuteNonQuery(); in Ado.Net


Hello friends !! Today I am just going to explain the concept of ExexuteNonQuery(); in ado.net which is as given below:

ExecuteNonQuery  !!
ExecuteNionQuery();
                                         The ExecuteNonQuery is an object which is executes the Sql Statement .ExecuteNonQuery does not return any value like insert, update. It returns no of row affected by the given Sql Statement.  

Source Code:

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

namespace project_ado.net_
{
    public partial class changepassword : Form
    {
        public changepassword()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("data source=.;initial catalog=project2;integrated security=true");
            SqlCommand cmd=new SqlCommand("update newuser set userpassword='"+new_pass.Text+"' where emailid='"+email_id.Text+"'and userpassword='"+currnet_pass.Text+"' ",con);
            con.Open();
            cmd.ExecuteNonQuery();
            MessageBox.Show("password changed ");

            con.Close();
         

        }

        private void button2_Click(object sender, EventArgs e)
        {
            NEWUSER nu = new NEWUSER();
            nu.Show();
        }
    }
}

Code  Screen:


                                                               Next Topic >>

 
I hope this post will help you ..
If you've some query regarding to this topic then please post your comment.your Comment will be appropriate..

0 comments:

Post a Comment

Hey thanax alot to comment i will revert you back soon...

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites