Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using CoreLab.PostgreSql;
namespace pgdFailure2 {
class Program {
static void Main( string[ ] args ) {
PgSqlConnection conn = new PgSqlConnection( );
conn.Database = "*****";
conn.Host = "sql";
conn.Port = 5432;
conn.UserId = "*****";
conn.Password = "*****";
conn.Unicode = true;
conn.Open( );
Console.WriteLine( "Connection successfull" );
PgSqlCommand cmd = new PgSqlCommand( "select pg_relation_size(:par_oid)", conn );
cmd.Parameters.Add( "par_oid", 19959 );
Console.WriteLine( "DbType = `{0}`, PgSqlType = `{1}`",
cmd.Parameters[ 0 ].DbType.ToString( ),
cmd.Parameters[ 0 ].PgSqlType.ToString( ) );
try {
object result = cmd.ExecuteScalar( );
Console.WriteLine( result.ToString( ) );
} catch( PgSqlException e ) {
Console.WriteLine( "ERROR: {0}", e.Message );
}
Console.WriteLine( "DbType = `{0}`, PgSqlType = `{1}`",
cmd.Parameters[ 0 ].DbType.ToString( ),
cmd.Parameters[ 0 ].PgSqlType.ToString( ) );
conn.Close( );
Console.ReadLine( );
}
}
}
Connection successfull
DbType = `Int32`, PgSqlType = `Int`
ERROR: relation "19959" does not exist
DbType = `AnsiString`, PgSqlType = `Text`