Blog Home  Home Feed your aggregator (RSS 2.0)  
What did you learn today? - 70-551 Section II Part VI - Data access
Phil Denoncourt's Technology Rants
 
 Sunday, February 26, 2006

UPGRADE: MCAD Skills to MCPD Web Developer by Using the Microsoft .NET Framework

Create, delete, and edit data in a connected environment.

  • Retrieve data by using a DataReader object.
  • Build SQL commands visually in Server Explorer.
  • Build SQL commands in code.
  • Create parameters for a command object.
  • Perform database operations by using a command object.
  • Retrieve data from a database by using a command object.
  • Perform asynchronous operations by using a command object.
  • Perform bulk copy operations to copy data to a SQL Server computer.
  • Store and retrieve binary large object (BLOB) data types in a database.

To use a DataReader, you create a command object, open the associated connection, and call the ExecuteDataReader method.

To build SQL Commands visually in Server Explorer, right click on the Database in the Server Explorer and select "New Query".

To build SQL Commands in code, you create a SQLCommand instance, set the commandtext property with the SQL Statement, add parameter objects to the parameters collection, and associate a connection to the command object.

Creating parameters is done by creating SqlParameter objects, setting the name, dbtype and value, and append to the command's parameters collection.

To perform database operations using a command object, invoke the ExecuteNonQuery method.  It executes the SQL statement of the command object and returns the number of rows affected.

To retrieve data using a command object, you can call the ExecuteDataReader, ExecuteScalar, or ExecuteXMLReader methods.

The command object now supports async operations.  There are BeginExecuteNonQuery, BeginExecuteDataReader, or BeginExecuteXmlReader methods.  Vishnu Prasad has a writeup on this at DevX.

They've added managed support for SQL Bulk Copies in the SqlBulkCopy class.  David Hayden has an example of how to use this class.

Working with Blobs isn't as hard as it used to be.  You just set the parameter's dbtype to SqlString and assign the large string to the parameter's value property.  No AppendChuck, GetChunk.  There is another method that I found interesting from Vadivel's blog.  I don't think that will be on the test.

Next up-> Composite Web Controls

Sunday, February 26, 2006 6:15:49 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Certifications  | 
Comments are closed.
Copyright © 2008 Phil Denoncourt III. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: