Monday 1 April 2013

SqlCommand in ado.net


Hello Friends !! Today I am just going to explain the concept of the SqlCommand in Ado.Net which as given below:
SqlCommand !!
SqlCommand:

  • The Main task of the SqlCommand is to execute the statement.
  • We use sqlcommand mostly in connected mode.
  • The Command Object required an instance of a Connection Object for executing the SQL statements
  • You can also call stored procedures with the command object.

The code window  screen and syntax for creating SqlCommand as given below:

Syntax:

SqlCommand cmd =new SqlCommand (“Sql Command”, connection);

Source Code:

using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void search_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("data source=.;initial catalog=search;integrated security=true");
            SqlCommand cmd = new SqlCommand("select *from find", con);
            con.Open();
       
               //body
            //body
             con.Close();
        }

Code window  Screen:


Sqlcommand has some important objects which are as given below:
                                                               Next Topic >>
I hope this post will hope ..
If you've some query regarding to this article then post your comment.Your comment will be appropriate.



1 comments:

The Main task of the SqlCommand is to execute the statement.We use sqlcommand mostly in connected mode.Thanks for your easy explanation. Dot Net Training in chennai | dot net training and placement in chennai

Post a Comment

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

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites