NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Managed Commands

Now that we can establish a connection, we need to be able to execute statements against the database. The simplest and most direct route for this is though the ADO and SQL Command objects.

ADOCommand

[VB]

Dim SQlStmt As String = "SELECT * FROM Customers"
Dim myCommand As ADOCommand = New ADOCommand(SQLStmt, myConnection)

[C#]

String SQLStmt = " SELECT * FROM Customers";
ADOCommand myCommand = new ADOCommand(SQLStmt, myConnection);

SQLCommand

[VB]

Dim SQlStmt As String = "SELECT * FROM Customers"
Dim myCommand As SQLCommand = New SQLCommand(SQLStmt, myConnection)
 

[C#]

String SQLStmt = " SELECT * FROM Customers";
SQLCommand myCommand = new SQLCommand(SQLStmt, myConnection);

With a command and connection, we can execute the query against the database. But first, one more object must be created before calling the command Execute method with the object as a parameter.

ADO

[VB]

Dim myReader As ADODataReader = Nothing
myCommand.Execute(myReader)

[C#]

ADODataReader myReader = null;
myCommand.Execute(out myReader);

SQL

[VB]

Dim myReader As SQLDataReader = Nothing
myCommand.Execute(myReader)

[C#]

SQLDataReader myReader = null;
myCommand.Execute(out myReader);

The example declares a variable that will hold the instantiated datareader that is returned as a parameter of the command's execute method.