Navigation:  Advantage .NET Data Provider > AdsConnection Class > AdsConnection Methods >

AdsConnection.CreateCommand

Advantage .NET Data Provider

Previous pageReturn to chapter overviewNext page

Creates and returns an AdsCommand object associated with the AdsConnection.

public AdsCommand CreateCommand();

Remarks

This method creates a new AdsCommand object that can be used for executing queries against the open connection. The AdsCommand.Connection property is automatically set when this method is used.

Example

AdsConnection conn = new AdsConnection( "data source = c:\\data;" );

AdsCommand cmd;

 

// open the connection

conn.Open();

// create a new command object

cmd = conn.CreateCommand();

// specify a query

cmd.CommandText = "select now() from system.iota";

// execute the query

Console.WriteLine( cmd.ExecuteScalar().ToString() );

// close the connection.

conn.Close();