|
October 13, 2002 The SqlCommand Class Tips: October 2002
Yehuda Shiran, Ph.D.
|
|
IBuySpy Store uses stored procedures to interact with the MSSQL database. Use the SqlCommand class to assemble an instance object with all the information required by the stored procedure. This class cannot be inherited. When created, the SqlCommand object points to the beginning of the database, for both read and write. This class includes four methods: ExecuteReader(), ExecuteNonQuery(), ExecuteScalar(), and ExecuteXmlReader().
ExecuteNonQuery() executes SQL queries such as INSERT, DELETE, UPDATE, and SET. Run ExecuteNonQuery() when you pass back information from the stored procedure through parameters as opposed to records. The GetProductDetail() method uses ExecuteNonQuery():
ExecuteScalar() retrieves a single value (for example, an aggregate value) from a database. ExecuteXmlReader() sends the CommandText to the Connection and builds an XmlReader object. The latter two methods are not used in IBuySpy.
People who read this tip also read these tips: Look for similar tips by subject: |