Command Object

After you create a connection, you can use the Command object to execute commands against the data source and return results. When creating a command, you must specify a SQL statement and a connection. Listing D.3 creates a new MyGolfGear.NET order using the Command object based on a stored procedure with parameters.

Listing D.3. Storing a Connectison String in web.config and Then Using It
1:  NameValueCollection config = NameValueCollection)HttpContext.Current. GetConfig
("appSettings"); 2: SqlConnection con = new SqlConnection((String)config["ConnectString"]); 3: SqlCommand com = new SqlCommand("spCreateNewOrder", con); 4: com.CommandType ...

Get Building e-Commerce Sites with the .NET Framework now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.