Wednesday 24 April 2013

What is the Command Class in .Net

We can send a request to DataSource specifying the type of action. We want to perform using an SQL statements like select,insert,update and delete. We user  commnad class for executing the statements.
Constructors : 
        command()
        Command(String sqlstmt, connection con)
Properties of Command :
 Connection :  Sets or Gets the current connection object associated with command.
CommandTest : sets or gets the statement associated with command.
Object of class command can be created as below


      Command cmd = new Command();
       cmd.connection= <con>;
        cmd.CommandTest="<sql stmt>";
                      (or)
        Command cmd = new Command("<Sql stmt>",con)

Methods of Command Class :
    ExecuteReader               DataReader
    ExecuteScalar                 object
    ExecuteNonQuery            int

No comments:

Post a Comment