Npgsql 0.6.0.0 1.0.5000.0 2.0.0.0 Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. System.ComponentModel.Component System.Data.IDbCommand System.ICloneable Represents a command to be executed against the PostgreSQL database backend.

An NpgsqlCommand object is associated with a instance.It can be used to execute SQL statements (SELECT, INSERT, UPDATE, DELETE, etc.), stored procedures and functions against the database the instance referenced in the is associated with.

As the NpgsqlCommand implements the interface, it can be used to

Execute queries without expecting a result back using the method
Execute queries only a single (scalar) result back using the method
Execute queries without expecting a back using the
- Constructor
  To be added
  To be added
  1.0.5000.0
  2.0.0.0
- Constructor
  a
  To be added
  To be added
  1.0.5000.0
  2.0.0.0
- Constructor
  a
  a
  To be added
  To be added
  1.0.5000.0
  2.0.0.0
- Constructor
  a
  a
  a
  To be added
  To be added
  1.0.5000.0
  2.0.0.0
- Method
  System.Void To be added To be added 1.0.5000.0 2.0.0.0
- Method
  1.0.5000.0
  2.0.0.0
  Npgsql.NpgsqlCommand To be added. To be added. To be added.
- Property
  System.String To be added a To be added 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue("") System.ComponentModel.Category("Data")
- Property
  System.Int32 To be added a To be added 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue(20)
- Property
  System.Data.CommandType To be added a To be added 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue(System.Data.CommandType.Text) System.ComponentModel.Category("Data")
- Property
  Npgsql.NpgsqlConnection Connection to the PostgreSQL backend a object The Connection property is a reference to the 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 is thrown. 1.0.5000.0 2.0.0.0 System.ComponentModel.DefaultValue(null) System.ComponentModel.Category("Behavior")
- Method
  Npgsql.NpgsqlParameter To be added a To be added 1.0.5000.0 2.0.0.0
- Method
  System.Int32 Executes a query against the database backend without expecting data back from it A containing the number of records affected on the database by the query

  The method is used to execute a query against the database without exepecting a result back. This is useful for running data manipulation commands, etc.

  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

  CREATE TABLE table1 (int1 INTEGER, int2 INTEGER); `/* 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(); } } }`

  Executing the query should give the output

  Just added 1 lines in the table table1 1.0.5000.0 2.0.0.0
- Method
  Npgsql.NpgsqlDataReader Executes a query against the database backend, creating a which can be used for forward-only reading of data from the database. a To be added 1.0.5000.0 2.0.0.0
- Method
  Npgsql.NpgsqlDataReader `` a To be added a To be added 1.0.5000.0 2.0.0.0
- Method
  System.Object Executes a query against the and expects a single value as output a containing the output value.

  This command returns a single value as the output of the command execution.

  `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(); } } }`

  Compiling and executing the above code gives the output

  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)

  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 `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(); } } }`

  still prints

  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)

  Note that the exact output in the above will vary depending on the exact version of the database.

  1.0.5000.0
  2.0.0.0
- Property
  1.0.5000.0
  2.0.0.0
  System.Int64 To be added. To be added. To be added.
- Property
  Npgsql.NpgsqlParameterCollection To be added a To be added 1.0.5000.0 2.0.0.0
- Method
  System.Void To be added To be added 1.0.5000.0 2.0.0.0
- Property
  1.0.5000.0
  2.0.0.0
  System.Data.IDbConnection To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  System.Data.IDbDataParameter To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  System.Data.IDataReader To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  System.Data.IDataReader `` To be added. To be added. To be added. To be added.
- Property
  1.0.5000.0
  2.0.0.0
  System.Data.IDataParameterCollection To be added. To be added. To be added.
- Property
  1.0.5000.0
  2.0.0.0
  System.Data.IDbTransaction To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  System.Object To be added. To be added. To be added.
- Property
  Npgsql.NpgsqlTransaction To be added a To be added 1.0.5000.0 2.0.0.0
- Property
  System.Data.UpdateRowSource To be added a To be added 1.0.5000.0 2.0.0.0