*/
Are you blogging on PH? Get your free blog.

Other Views

corner
*/

ADONET FAQ - Supplying SQL Query to ADO.Net

How do I create a command and supply the SQL query to ADO.Net? (Command object and command string)

First of all, you create a command object (SqlCommand, OracleCommand, OleDbCommand, OdbcCommand) using the connection object (SqlConnection, OracleConnection, OleDbConnection, OdbcConnection) and set its CommandText property to the SQL query to execute.

C# Version
OdbcCommand cmd = conn.CreateCommand();
cmd.CommandText = "select * from authors";


VB.Net Version
Dim cmd As OdbcCommand 
cmd = conn.CreateCommand()
cmd.CommandText = "select * from authors"


Back
corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.