All You Need to Know about ADO.NET: Part 2/2
page 2 of 27
by Devarticles.com
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 54950/ 464

Command Object
A command object is used for executing a query against the database. ADO command objects are equivalent to DataAdapters that hold the actual query. It needs an established connection, it's command type and commandtext properties to be set before calling its Execute method.

The SQLCommand object is analogous to the command object in ADO. We also need a connection for execution. The DataAdapter supports read, add, update and delete operations and for these it supports following properties:
  1. SelectCommand
  2. UpdateCommand
  3. InsertCommand
  4. DeleteCommand

Actually, these properties are objects. To be mores specific, these are instances of the SQLCommand object. Unless otherwise specified, the appropriate objects are generated at runtime automatically. The SelectCommand can be edited at design time while configuring the DataAdapter. The command objects can be executed independently by using their execute methods. Important properties of the object are CommandType and CommandText. If the CommandType property is set to StoredProcedure, then CommandText property should be set to the name of the stored procedure, otherwise the CommandText property contains the actual query.

To see a command working, let's use following piece of code:

Dim sqlSttg As String = "SELECT * FROM Publishers"
Dim cmd As New OleDBCommand (cmd.CommandText = sqlSttg
cmd.ActiveConnection = Conn

[Note] This code assumes that you have a connection to data (Conn open as discussed in the previous example). [End Note]


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 3 and 5 and type the answer here:

User Comments

Title: Thanks   
Name: Amin Anwar
Date: 5/14/2009 5:19:09 AM
Comment:
That isgr8 collection;;;
thanks
Title: Ado.net   
Name: Saurabh Shrivastava
Date: 2/20/2007 11:46:46 AM
Comment:
Brilliant Work,It could be more useful by giving some code in it.
Title: Thank you   
Name: Jayalakshmi baskaran
Date: 5/30/2006 5:39:23 AM
Comment:
I want to create the sqldataAdapter and the Dataset in Code
Can you please help it out
Title: Ado.Net   
Name: Rohan Ragoo
Date: 1/9/2006 12:37:59 PM
Comment:
Excellent Overview. All topics are dicussed in an effective timeline.
Title: XML   
Name: Rajesh Medackel,India
Date: 10/1/2005 5:26:30 AM
Comment:
Good write up .... Thanx
Title: ADO.Net   
Name: k
Date: 5/3/2005 11:31:30 AM
Comment:
to the authors thanks a lot for the unselfish information

Product Spotlight
Product Spotlight 






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2009 ASPAlliance.com  |  Page Processed at 11/8/2009 8:04:33 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search