<Type Name="NpgsqlCommand" FullName="Npgsql.NpgsqlCommand">
  <TypeSignature Language="C#" Value="public sealed class NpgsqlCommand : IDbCommand, IDisposable" Maintainer="auto" />
  <AssemblyInfo>
    <AssemblyName>Npgsql</AssemblyName>
    <AssemblyPublicKey>
    </AssemblyPublicKey>
    <AssemblyVersion>0.6.0.0</AssemblyVersion>
    <AssemblyCulture>neutral</AssemblyCulture>
    <Attributes />
  </AssemblyInfo>
  <ThreadSafetyStatement>Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details.</ThreadSafetyStatement>
  <Docs>
    <summary>Represents a command to be executed against the PostgreSQL database backend.</summary>
    <remarks>
      <para>
		An NpgsqlCommand object is associated with a <see cref="T:Npgsql.NpgsqlConnection" /> instance.It can be used to execute
		SQL statements (SELECT, INSERT, UPDATE, DELETE, etc.), stored procedures and functions against the database the <see cref="T:Npgsql.NpgsqlConnection" />
		instance referenced in the <see cref="P:Npgsql.NpgsqlCommand.Connection" /> is associated with.
	</para>
      <para>
		As the NpgsqlCommand implements the <see cref="T:System.Data.IDbCommand" /> interface, it can be used to
		<list type="bullet">
          <item>
            <term>Execute queries without expecting a result back using the 
				<see cref="M:Npgsql.NpgsqlCommand.ExecuteNonQuery" /> method</term>
          </item>
          <item>
            <term>Execute queries only a single (scalar) result back using the
				<see cref="M:Npgsql.NpgsqlCommand.ExecuteScalar" /> method</term>
          </item>
          <item>
            <term>Execute queries without expecting a
				<see cref="Npgsql.NpgsqlDataReader" /> back using the <see cref="M:Npgsql.NpgsqlCommand.ExecuteDataReader" /></term>
          </item>
        </list></para>
    </remarks>
  </Docs>
  <Base>
    <BaseTypeName>System.Object</BaseTypeName>
  </Base>
  <Interfaces>
    <Interface>
      <InterfaceName>System.Data.IDbCommand</InterfaceName>
    </Interface>
    <Interface>
      <InterfaceName>System.IDisposable</InterfaceName>
    </Interface>
  </Interfaces>
  <Attributes />
  <Members>
    <Member MemberName="Cancel">
      <MemberSignature Language="C#" Value="public virtual void Cancel ();" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="CreateParameter">
      <MemberSignature Language="C#" Value="public Npgsql.NpgsqlParameter CreateParameter ();" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>Npgsql.NpgsqlParameter</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <returns>a <see cref="T:Npgsql.NpgsqlParameter" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="ExecuteNonQuery">
      <MemberSignature Language="C#" Value="public virtual int ExecuteNonQuery ();" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Int32</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>Executes a query against the database backend without expecting data back from it</summary>
        <returns>A <see cref="T:System.Int32" /> containing the number of records affected on the database by the query</returns>
        <remarks>
          <para>
				The <see cref="M:Npgsql.NpgsqlCommand.ExecuteNonQuery" /> method is used to execute a query against the database
				without exepecting a result back. This is useful for running data manipulation commands, etc.
			</para>
          <para>
				The following example demonstrates the use of the method against a database. For the example to work, a user 'joe'
				with the password 'secret' needs to have access to the 'table1' table in the 'joedata' database created with the SQL
			</para>
          <c>
				CREATE TABLE table1 (int1 INTEGER, int2 INTEGER);
			</c>
          <code lang="C#">
/* Compiling:
 * 	mcs -r:Npgsql -r:System.Data NpgsqlExecuteNonQuery.cs
 */
using System;
using System.Data;
using Npgsql;

public class NpgsqlExecuteNonQuery
{
	public static void Main(String[] args)
	{
		NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;");
		conn.Open();
		
		NpgsqlCommand command = new NpgsqlCommand("insert into table1 values(1, 1)", conn);
		Int32 rowsaffected;
		
		try
		{
			rowsaffected = command.ExecuteNonQuery();
			Console.WriteLine("Just added {0} lines in the table table1", rowsaffected);
		}
		finally
		{
			conn.Close();
		}
	}
} 
			</code>
          <para>
			Executing the query should give the output
			</para>
          <c>Just added 1 lines in the table table1</c>
        </remarks>
      </Docs>
    </Member>
    <Member MemberName="ExecuteReader">
      <MemberSignature Language="C#" Value="public Npgsql.NpgsqlDataReader ExecuteReader ();" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>Npgsql.NpgsqlDataReader</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>Executes a query against the database backend, creating a <see cref="T:Npgsql.NpgsqlDataReader" />
which can be used for forward-only reading of data from the database.</summary>
        <returns>a <see cref="T:Npgsql.NpgsqlDataReader" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="ExecuteReader">
      <MemberSignature Language="C#" Value="public Npgsql.NpgsqlDataReader ExecuteReader (System.Data.CommandBehavior cb);" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>Npgsql.NpgsqlDataReader</ReturnType>
      </ReturnValue>
      <Parameters>
        <Parameter Name="cb" Type="System.Data.CommandBehavior" />
      </Parameters>
      <Docs>
        <summary>To be added</summary>
        <param name="cb">a <see cref="T:System.Data.CommandBehavior" /></param>
        <returns>a <see cref="T:Npgsql.NpgsqlDataReader" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="ExecuteScalar">
      <MemberSignature Language="C#" Value="public virtual object ExecuteScalar ();" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Object</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>Executes a query against the <see cref="T:Npgsql.NpgsqlConnection" /> and expects a single value as output</summary>
        <returns>a <see cref="T:System.Object" /> containing the output value.</returns>
        <remarks>
          <para>
			This command returns a single value as the output of the command execution.
		</para>
          <code lang="C#">
using System;
using System.Data;
using Npgsql;

public class NpgsqlExecuteScalar
{
	public static void Main(String[] args)
	{
		NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;");
		conn.Open();
		
		NpgsqlCommand command = new NpgsqlCommand("select version()", conn);
		String serverversion;
		
		try
		{
			serverversion = (String)command.ExecuteScalar();
			Console.WriteLine("PostgreSQL server version: {0}", serverversion);
		}
		finally
		{
			conn.Close();
		}
	}
}
		</code>
          <para>
			Compiling and executing the above code gives the output
		</para>
          <c>PostgreSQL server version: PostgreSQL 7.3.2 on i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.2.2 20030213 (Red Hat Linux 8.0 3.2.2-1)</c>
          <para>
			If a query is executed that returns more than one column and/or more than one row, only the first column in the first row is returned.
			
			For example, tweaking the above example to make it
		<code Lang="C#">
using System;
using System.Data;
using Npgsql;

public class NpgsqlExecuteScalar
{
	public static void Main(String[] args)
	{
		NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;");
		conn.Open();
		
		NpgsqlCommand command = new NpgsqlCommand("select version(), upper('foo')", conn);
		String serverversion;
		
		try
		{
			serverversion = (String)command.ExecuteScalar();
			Console.WriteLine("PostgreSQL server version: {0}", serverversion);
		}
		finally
		{
			conn.Close();
		}
	}
}
		</code>
		
		still prints
		</para>
          <c>PostgreSQL server version: PostgreSQL 7.3.2 on i386-redhat-linux-gnu, compiled by GCC i386-redhat-linux-gcc (GCC) 3.2.2 20030213 (Red Hat Linux 8.0 3.2.2-1)</c>
          <para>
			Note that the exact output in the above will vary depending on the exact version of the database.
		</para>
        </remarks>
      </Docs>
    </Member>
    <Member MemberName="Prepare">
      <MemberSignature Language="C#" Value="public virtual void Prepare ();" />
      <MemberType>Method</MemberType>
      <ReturnValue>
        <ReturnType>System.Void</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public NpgsqlCommand ();" />
      <MemberType>Constructor</MemberType>
      <ReturnValue />
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <returns>a <see cref="T:Npgsql.NpgsqlCommand" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public NpgsqlCommand (string cmdText);" />
      <MemberType>Constructor</MemberType>
      <ReturnValue />
      <Parameters>
        <Parameter Name="cmdText" Type="System.String" />
      </Parameters>
      <Docs>
        <summary>To be added</summary>
        <param name="cmdText">a <see cref="T:System.String" /></param>
        <returns>a <see cref="T:Npgsql.NpgsqlCommand" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public NpgsqlCommand (string cmdText, Npgsql.NpgsqlConnection connection);" />
      <MemberType>Constructor</MemberType>
      <ReturnValue />
      <Parameters>
        <Parameter Name="cmdText" Type="System.String" />
        <Parameter Name="connection" Type="Npgsql.NpgsqlConnection" />
      </Parameters>
      <Docs>
        <summary>To be added</summary>
        <param name="cmdText">a <see cref="T:System.String" /></param>
        <param name="connection">a <see cref="T:Npgsql.NpgsqlConnection" /></param>
        <returns>a <see cref="T:Npgsql.NpgsqlCommand" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="CommandText">
      <MemberSignature Language="C#" Value="public virtual string CommandText { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.String</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <returns>a <see cref="T:System.String" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="CommandTimeout">
      <MemberSignature Language="C#" Value="public virtual int CommandTimeout { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Int32</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <returns>a <see cref="T:System.Int32" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="CommandType">
      <MemberSignature Language="C#" Value="public virtual System.Data.CommandType CommandType { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Data.CommandType</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <returns>a <see cref="T:System.Data.CommandType" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="Connection">
      <MemberSignature Language="C#" Value="public Npgsql.NpgsqlConnection Connection { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>Npgsql.NpgsqlConnection</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>Connection to the PostgreSQL backend</summary>
        <returns>a <see cref="T:Npgsql.NpgsqlConnection" /> object</returns>
        <remarks>
			The Connection property is a reference to the <see cref="T:Npgsql.NpgsqlConnection" /> the commands will be executed against.
			The connection must be open before the command can be executed. If a command is executed against a closed connection,
			a <see cref="T:System.InvalidOperationException" /> is thrown.
		</remarks>
      </Docs>
    </Member>
    <Member MemberName="Parameters">
      <MemberSignature Language="C#" Value="public Npgsql.NpgsqlParameterCollection Parameters { get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>Npgsql.NpgsqlParameterCollection</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <returns>a <see cref="T:Npgsql.NpgsqlParameterCollection" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="Transaction">
      <MemberSignature Language="C#" Value="public virtual System.Data.IDbTransaction Transaction { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Data.IDbTransaction</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <returns>a <see cref="T:System.Data.IDbTransaction" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName="UpdatedRowSource">
      <MemberSignature Language="C#" Value="public virtual System.Data.UpdateRowSource UpdatedRowSource { set; get; };" />
      <MemberType>Property</MemberType>
      <ReturnValue>
        <ReturnType>System.Data.UpdateRowSource</ReturnType>
      </ReturnValue>
      <Parameters />
      <Docs>
        <summary>To be added</summary>
        <returns>a <see cref="T:System.Data.UpdateRowSource" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
    <Member MemberName=".ctor">
      <MemberSignature Language="C#" Value="public NpgsqlCommand (string cmdText, Npgsql.NpgsqlConnection connection, Npgsql.NpgsqlTransaction transaction);" />
      <MemberType>Constructor</MemberType>
      <ReturnValue />
      <Parameters>
        <Parameter Name="cmdText" Type="System.String" />
        <Parameter Name="connection" Type="Npgsql.NpgsqlConnection" />
        <Parameter Name="transaction" Type="Npgsql.NpgsqlTransaction" />
      </Parameters>
      <Docs>
        <summary>To be added</summary>
        <param name="cmdText">a <see cref="T:System.String" /></param>
        <param name="connection">a <see cref="T:Npgsql.NpgsqlConnection" /></param>
        <param name="transaction">a <see cref="T:Npgsql.NpgsqlTransaction" /></param>
        <returns>a <see cref="T:Npgsql.NpgsqlCommand" /></returns>
        <remarks>To be added</remarks>
      </Docs>
    </Member>
  </Members>
</Type>