<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3593194529034575387</id><updated>2024-08-30T20:00:35.883+05:30</updated><title type='text'>OpenTips</title><subtitle type='html'>                                                                                                                   Just Sharing ...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sathees</name><uri>http://www.blogger.com/profile/02011018968515594961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-6073372528694312654</id><published>2009-10-06T11:41:00.001+05:30</published><updated>2009-10-06T11:41:42.847+05:30</updated><title type='text'>INTERRUPT SERVICE ROUTINE (IRQ)</title><content type='html'>******************INTERRUPT SERVICE ROUTINE (IRQ) **************&lt;br /&gt;&lt;br /&gt;IRQ Driver:::::::: I2C&lt;br /&gt;MASTER   :::::::  LPC2368 (ARM 7)&lt;br /&gt;&lt;br /&gt;Do’s &amp;amp; Don’ts of ISR: 1. The variables declared inside an Interrupt should be declared using &quot;volatile&quot; Keyword . Only after declaring &quot;volatile&quot; , user may get the desired output . for eg : global var declaration area : volatile unsigned char MasterBuff[23] = {0}; __irq void I2C_IRQHnadler(void) { ...................... ...................... MasterBuff[Index] = I21DAT ; } 2. Before the termination of ISR block , please clear the I2C Interrupt Flag and Acknowledge the Interrupt like shown below . eg : __irq void I2C_IRQHnadler(void) { ..................................... ..................................... I21CONCLR=0x08; /*Clear Interrupt Flag */ VICVectAddr = 0; /*Acknowledge Interrupt */ } 3. Always Clear the I2C Interrupt Registers before Initializing it to some desired value . 4. While Initializing I2C Interrupt follow this order, First Set the Priority of the ISR &#39;1&#39; is Highest Priority and &#39;15&#39; is lowest priority , then Enable the specific Vector Address bit for powering on the desired ISR(like UART,Timer,I2C,etc.,) block . 5.Considering the I2C IRQ , it is basically a state machine where we have unique states for generating repeated start , read/write operation etc.,So under each states we have to follow the desired protocol for setting values in I2C Interrupt Registers as in the data sheet . 6. Always make sure before using any registers that belong to I2C , clear everything in the main() routine.&lt;br /&gt;&lt;br /&gt;7. Do not Call any function inside an IRQ , this will result in malfunctioning of the whole routine . Let the IRQ be as small as possible .&lt;br /&gt;&lt;br /&gt;Please feel free to add comments and suggestions on the above issues of Interrupts .&lt;br /&gt;&lt;br /&gt;Adidos !Regards,&lt;br /&gt;Samjith.***************************************</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/6073372528694312654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/6073372528694312654' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6073372528694312654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6073372528694312654'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2009/10/interrupt-service-routine-irq.html' title='INTERRUPT SERVICE ROUTINE (IRQ)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-6602715706992653112</id><published>2008-10-31T11:01:00.000+05:30</published><updated>2008-10-31T11:11:16.148+05:30</updated><title type='text'>IPaddress blocking in HTTPD for FC8</title><content type='html'>In FC8 system comment the code for following line&lt;br /&gt;&quot;check for the host is not IP address&quot;  in both the files&lt;br /&gt;1. /etc/httpd/modsecurity.d/blocking/modsecurity_crs_21_protocol_anomolies.conf&lt;br /&gt;2. /etc/httpd/modsecurity.d/modsecurity_crs_21_protocol_anomolies.conf&lt;br /&gt;&lt;br /&gt;    This will disable the bolcking of IP Address in browsing  to  view the php pages.</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/6602715706992653112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/6602715706992653112' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6602715706992653112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6602715706992653112'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/10/ipaddress-blocking-in-httpd-for-fc8.html' title='IPaddress blocking in HTTPD for FC8'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-6151520569948606222</id><published>2008-04-01T17:50:00.000+05:30</published><updated>2008-04-01T18:26:17.895+05:30</updated><title type='text'></title><content type='html'>&lt;span style=&quot;font-size:130%;&quot;&gt;Postgresql Installation Error &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Installation Error for &lt;/span&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;postgresql 8.1.0&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(102, 102, 102);&quot;&gt;Error Message &lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: rgb(102, 102, 102);&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: rgb(102, 102, 102);&quot;&gt;Failed to get system.metric service terminal : 87&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This error can occur when the windows  doesn&#39;t support the old postgresql version &lt;br /&gt;please try to install the lastest postgresql version&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;postgresql 8.3.0 commands&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;cmd to take  database dump &lt;br /&gt;#pg_dump -U postgres -c -f dbdump_name.sql dbname&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 0);&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;cmd to load the dump&lt;br /&gt;&lt;span style=&quot;color: rgb(51, 51, 51);&quot;&gt;# psql -U postgres -d dbname -f dbdump_name.sql&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/6151520569948606222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/6151520569948606222' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6151520569948606222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6151520569948606222'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/04/postgresql-installation-error.html' title=''/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-4011344921401680416</id><published>2008-03-27T11:26:00.000+05:30</published><updated>2008-03-27T16:30:31.332+05:30</updated><title type='text'>IPtables For Outlook Express Mails</title><content type='html'>A Squid proxy can share a Internet Service. But it will not download the mails in Outlook Express.&lt;br /&gt;In this case IPtables can be used to retrieve mails.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;A model Network setup:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Eth0 : Public N/W&lt;br /&gt;&lt;br /&gt;Eth1 : Private N/W&lt;br /&gt;IP Range : 192.168.10.0/24&lt;br /&gt;&lt;br /&gt;So hence the Iptables rules for forwarding the packets ,&lt;br /&gt;&lt;br /&gt;# iptables --table nat --append POSTROUTING -s 192.168.10.0/24 --out-interface eth1 -j MASQUERADE&lt;br /&gt;&lt;br /&gt;# iptables --append FORWARD -s 192.168.10.0/24 --in-interface eth0 -j ACCEPT&lt;br /&gt;&lt;br /&gt;# iptables -A INPUT -s 192.168.10.0/24 -j ACCEPT&lt;br /&gt;&lt;br /&gt;Insert the above rules,&lt;br /&gt;Save and restart the service&lt;br /&gt;&lt;br /&gt;#service iptables save&lt;br /&gt;# service iptables restart&lt;br /&gt;Now you can download your mails in the Outlook express.&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Client Side Configuration:&lt;br /&gt;&lt;/strong&gt;1. Set the Gateway address as Eth1 IP.&lt;br /&gt;2. Open Outlook Express – Tools – Accounts – mail – add new&lt;br /&gt;3. Configure your mail account.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/4011344921401680416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/4011344921401680416' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/4011344921401680416'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/4011344921401680416'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/03/iptables-for-outlook-express-mails.html' title='IPtables For Outlook Express Mails'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-952225114373140174</id><published>2008-02-05T17:47:00.001+05:30</published><updated>2008-02-05T17:59:10.094+05:30</updated><title type='text'>SELinux configuring for php postgresql connection in Linux</title><content type='html'>Configuring SELinux&lt;br /&gt;&lt;br /&gt;The following command will disbale the SELinux. This will allow php to connect with the postgresql database.&lt;br /&gt;Run the following command in the terminal&lt;br /&gt;&lt;br /&gt;/usr/sbin/setsebool -P httpd_disable_trans 1&lt;br /&gt;&lt;br /&gt;/sbin/service httpd restart</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/952225114373140174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/952225114373140174' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/952225114373140174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/952225114373140174'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/02/selinux-configuring-for-php-postgresql.html' title='SELinux configuring for php postgresql connection in Linux'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-3871967391136726030</id><published>2008-01-30T11:05:00.000+05:30</published><updated>2008-01-30T11:09:29.812+05:30</updated><title type='text'>Npgsql is a .Net Data Provider for the PostgreSQL Database Server</title><content type='html'>&lt;p&gt;&lt;a href=&quot;http://pgfoundry.org/projects/npgsql/&quot;&gt;Npgsql &lt;/a&gt;is a .Net Data  Provider for the &lt;a href=&quot;http://www.postgresql.org/&quot;&gt;PostgreSQL Database  Server&lt;/a&gt;. &lt;/p&gt;  It allows a .Net client application (Console, WinForms, ASP.NET, Web  Services...) to send and receive data with a PostgreSQL server.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;2. How to get and compile Npgsql &lt;/h2&gt;  &lt;h3&gt;2.1 Binary package &lt;/h3&gt;  &lt;p&gt;You can download Npgsql compiled for MS.Net and Mono in the &lt;a href=&quot;http://pgfoundry.org/frs/?group_id=1000140&quot;&gt;Files section &lt;/a&gt;of the  project.&lt;/p&gt;  &lt;p&gt;Inside this package, you will find the following directory layout: &lt;/p&gt;  &lt;p&gt;Npgsql/bin/docs - Documentation &lt;/p&gt;  &lt;p&gt;Npgsql/bin/docs/apidocs - API Documentation &lt;/p&gt;  &lt;p&gt;Npgsql/bin/ms1.1 - Npgsql compiled for MS.Net 1.1 &lt;/p&gt;  &lt;p&gt;Npgsql/bin/mono - Npgsql compiled for Mono &lt;/p&gt;  &lt;p&gt;As soon as Npgsql is released on other platforms/versions, they will be added  accordingly to this layout. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;2.2 Installing binary package &lt;/h3&gt;  &lt;p&gt;In order for the .Net Runtime to locate the Npgsql.dll library, this file  must be placed in your application directory- unless you specify another  directory as a path to private components through a configuration file (using  the probing element). Please see the .Net docs for information on how the  runtime probes (locates) assemblies to be loaded. Specifically, see the section  called &quot;Path to Private Components&quot; &lt;/p&gt;  &lt;p&gt;In ASP.NET and Web Services .Net Applications, there must be a directory  called &quot;bin&quot; below the ASP.NET root application directory. For example, if the  application directory is called &quot;ASPNETApplication&quot;, then Npgsql.dll and  Mono.Security.dll must be placed in the &quot;ASPNETApplication\bin&quot; directory. If  these files are not in the right directory, you can expect to see the compiler  generate errors on code that uses Npgsql classes.&lt;/p&gt;  &lt;p&gt;Alternatively, you can put the Npgsql assembly in the Global Assembly Cache  (GAC). Since version 0.4, Npgsql is strongly signed- meaning that you can use  &quot;gacutil&quot; to install it. Simply issue the following command:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;gacutil -i Npgsql.dll&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;Please refer to &quot;Installing an Assembly in the Global Cache Assembly&quot; section  of MSDN docs for more information. Use of the GAC has implications that you  should fully understand before going down this path.  &lt;/p&gt; &lt;p&gt;Note that placing Npgsql in the GAC is required for Npgsql design time  support in Visual Studio .Net.  &lt;/p&gt; &lt;p&gt;(Npgsql compiled for Mono doesn&#39;t require Mono.Security.dll as it&#39;s already  integrated in the Mono Runtime.)&lt;/p&gt;  &lt;p&gt;Once you copy or set up the assemblies, you&#39;re ready to try the examples-  jump to &lt;a href=&quot;http://npgsql.projects.postgresql.org/docs/manual/UserManual.html#section3&quot;&gt;section  3&lt;/a&gt;. &lt;/p&gt;  &lt;h3&gt;2.3 Getting Npgsql from CVS &lt;/h3&gt;  &lt;p&gt;To get Npgsql from CVS, use the following info in your CVS client:  &lt;/p&gt; Server: cvs.pgfoundry.org&lt;br /&gt;Repository: /cvsroot/npgsql&lt;br /&gt;Module name:  Npgsql&lt;br /&gt;User: anonymous&lt;br /&gt;Password:  &lt;p&gt;If you are using CVS from a command line, use this command: &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;cvs -d :pserver:anonymous@cvs.pgfoundry.org:/cvsroot/npgsql login&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Hit the Enter key when prompted for a password (none required):&lt;br /&gt;&lt;pre class=&quot;CodeBox&quot;&gt;cvs -d :pserver:anonymous@cvs.pgfoundry.org:/cvsroot/npgsql checkout Npgsql&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;The code will begin transferring: &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;$ cvs -d :pserver:anonymous@cvs.pgfoundry.org:/cvsroot/npgsql login&lt;br /&gt;Logging in to :pserver:anonymous@cvs.pgfoundry.org:2401/cvsroot/npgsql&lt;br /&gt;CVS password:&lt;br /&gt;$ cvs -d :pserver:anonymous@cvs.pgfoundry.org:/cvsroot/npgsql co Npgsql&lt;br /&gt;cvs checkout: Updating Npgsql&lt;br /&gt;cvs checkout: Updating Npgsql/admin&lt;br /&gt;U Npgsql/admin/release.pl&lt;br /&gt;cvs checkout: Updating Npgsql/docs&lt;br /&gt;U Npgsql/docs/Npgsql.zargo&lt;br /&gt;U Npgsql/docs/NpgsqlConnectionStateMachine.png&lt;br /&gt;U Npgsql/docs/SuggestedReadings.htm&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;2.4 Compiling Npgsql&lt;/h3&gt;  &lt;p&gt;The officially supported method for compiling Npgsql is &lt;a href=&quot;http://nant.sf.net/&quot;&gt;NAnt&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Simply run &lt;i&gt;nant&lt;/i&gt; from the Npgsql/src/Npgsql folder and you&#39;re done. It  will create a folder named &quot;build&quot;; see the &quot;build/ms&quot; folder for the resulting  assemblies.&lt;/p&gt;  &lt;p&gt;To run nUnit tests, simply run &lt;i&gt;nant tests&lt;/i&gt;. Note that first you need to  prepare the database for testing by executing &quot;add_* scripts&quot; in the  Npgsql/src/testsuite/noninteractive folder.  &lt;/p&gt; &lt;p&gt;We will provide solution projects for other development platforms such as  Visual Studio .Net, SharpDevelop, and MonoDevelop. (We have already received  reports of successful solution projects created for these other environments and  will make them available soon.)&lt;/p&gt;  &lt;h2&gt;&lt;a name=&quot;section3&quot;&gt;&lt;/a&gt;3. Npgsql Usage &lt;/h2&gt;  &lt;p&gt;This section explains Npgsql usage in a .Net application (Windows or  ASP.NET). If you have experience developing data access applications using the  Sql Server, OleDB or ODBC.NET providers, you will find that Npgsql is very  similar, in most respects equally or more robust, and backed by an active  community.&lt;/p&gt;  &lt;p&gt;In order to use Npgsql, the PostgreSQL server must be listening to TCP/IP  connections. TCP connections are enabled by default on 8.0 + servers. Previous  versions should have postmaster started with the &quot;-i&quot; option. Check PostgreSQL  Documentation for details: &lt;a href=&quot;http://www.postgresql.org/docs/7.4/static/postmaster-start.html&quot;&gt;http://www.postgresql.org/docs/7.4/static/postmaster-start.html&lt;/a&gt;  &lt;/p&gt;  &lt;p&gt;Note: Npgsql is still under development. Only features currently supported  will be demonstrated. As Npgsql matures, more functionality will become  available. &lt;/p&gt;  &lt;h3&gt;Adding required namespaces to your source file &lt;/h3&gt;  &lt;p&gt;First, in order to access Npgsql objects more easily (i.e. Intellisense in  Visual Studio .Net), you need to instruct the compiler to use the Npgsql  namespace. As you manipulate data retrieved by Npgsql, classes in System.Data  will also be required. In C#, add this directive to the appropriate page or  class: &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;If you are using ASP.NET without code-behind files, you may need to add the  following lines in top of your ASPX pages: &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;&lt;%@ Assembly name=&quot;System.Data&quot; %&gt;&lt;br /&gt;&lt;%@ Assembly name=&quot;Npgsql&quot; %&gt;&lt;br /&gt;&lt;/pre&gt; You can read more details here &lt;a href=&quot;http://www.mono-project.com/FAQ:_ASP.NET&quot;&gt;FAQ Mono Page about ASP.NET&lt;/a&gt;  &lt;h3&gt;Establishing a connection &lt;/h3&gt;  &lt;p&gt;To establish a connection to a server located at IP 127.0.0.1, port 5432, as  user &quot;joe&quot;, with password &quot;secret&quot;, on database &quot;joedata&quot;, open NpgsqlConnection  with the following connection string:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;   NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;   conn.Open();&lt;br /&gt;   conn.Close();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Connection String parameters &lt;/h3&gt;  &lt;p&gt;When establishing a connection, NpgsqlConnection accepts many parameters  which modify its behavior. Here is the list of current parameters you can tweak:  (From NpgsqlConnection source) &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt; Gets or sets the string used to connect to a PostgreSQL database.&lt;br /&gt;       /// Valid values are:&lt;br /&gt;       /// Server:                     Address/Name of PostgreSQL Server;&lt;br /&gt;       /// Port:                       Port to connect to;&lt;br /&gt;       /// Protocol:                   Protocol version to use, instead of automatic; Integer 2 or 3;&lt;br /&gt;       /// Database:                   Database name. Defaults to user name if not specified;&lt;br /&gt;       /// User Id:                    User name;&lt;br /&gt;       /// Password:                   Password for clear text authentication;&lt;br /&gt;       /// SSL:                        True or False. Controls whether to attempt a secure connection. Default = False;&lt;br /&gt;       /// Pooling:                    True or False. Controls whether connection pooling is used. Default = True;&lt;br /&gt;       /// MinPoolSize:                Min size of connection pool. Default: 1;&lt;br /&gt;       /// MaxPoolSize:                Max size of connection pool. Default: 20;&lt;br /&gt;       /// Encoding:                   Encoding to be used; Can be ASCII or UNICODE. Default is ASCII. Use UNICODE if you are having problems with accents.&lt;br /&gt;       /// Timeout:                    Time to wait for connection open in seconds. Default is 15.&lt;br /&gt;       /// CommandTimeout:             Time to wait for command to finish execution before throw an exception. In seconds. Default is 20.&lt;br /&gt;       /// Sslmode:                    Mode for ssl connection control.&lt;br /&gt;       /// ConnectionLifeTime:         Time to wait before closing unused connections in the pool, in seconds. Default is 15.&lt;br /&gt;       /// SyncNotification:           Specifies if Npgsql should use synchronous notifications&lt;br /&gt;       Encoding can be ASCII or UNICODE. If your application uses characters with accents and it doesn&#39;t work with the default settings, try changing it.&lt;br /&gt;       Min pool size, when specified, will make NpgsqlConnection pre-allocate the specified number of connections with the server.&lt;br /&gt;       Sslmode can be one of the following values:&lt;br /&gt;           Prefer - If it is possible to connect via SLL, SSL will be used.&lt;br /&gt;           Require - If an SSL connection cannot be established, an exception is thrown.&lt;br /&gt;           Allow - Not supported yet; connects without SSL.&lt;br /&gt;           Disable - No SSL connection is attempted.&lt;br /&gt;           The default value is &quot;Disable&quot;.&lt;br /&gt;      &lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Using NpgsqlCommand to add a row in a table &lt;/h3&gt;  &lt;p&gt;The previous example doesn&#39;t do anything useful. It merely connects to the  database and disconnects. If there is an error, a NpgsqlException is thrown.  Now, suppose you have a table called &quot;table1&quot; with two fields, &quot;fielda&quot; and  &quot;fieldb&quot;, both of type int. If you want to insert tuple (1, 1) in this table you  can send the insert statement:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;   NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;   conn.Open();&lt;br /&gt;  &lt;br /&gt;   NpgsqlCommand command = new NpgsqlCommand(&quot;insert into table1 values(1, 1)&quot;, conn);&lt;br /&gt;   Int32 rowsaffected;&lt;br /&gt;  &lt;br /&gt;   try&lt;br /&gt;   {&lt;br /&gt;     rowsaffected = command.ExecuteNonQuery();&lt;br /&gt;   &lt;br /&gt;     Console.WriteLine(&quot;It was added {0} lines in table table1&quot;, rowsaffected);&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   finally&lt;br /&gt;   {&lt;br /&gt;     conn.Close();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; ExecuteNonQuery() is ideally suited for insert and update queries because  it returns an integer indicating the number of rows affected by the last  operation.  &lt;h3&gt;Getting a single result value using the NpgsqlCommand.ExecuteScalar() method  &lt;/h3&gt;  &lt;p&gt;In some scenarios, you only need to retrieve a single value (scalar) from a  function. Use the ExecuteScalar() method on a Command object :&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;   NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;   conn.Open();&lt;br /&gt;  &lt;br /&gt;   NpgsqlCommand command = new NpgsqlCommand(&quot;select version()&quot;, conn);&lt;br /&gt;   String serverversion;&lt;br /&gt;  &lt;br /&gt;   try&lt;br /&gt;   {&lt;br /&gt;     serverversion = (String)command.ExecuteScalar();&lt;br /&gt;     Console.WriteLine(&quot;PostgreSQL server version: {0}&quot;, serverversion);&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;  &lt;br /&gt;   finally&lt;br /&gt;   {&lt;br /&gt;     conn.Close();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; You may also use ExecuteScalar against queries that return a recordset,  such as &quot;select count(*) from table1&quot;. However, when calling a function that  returns a set of one or more records, only the first column of the first row is  returned (DataSet.Tables[0].Rows[0][0]). In general, any query that returns a  single value should be called with Command.ExecuteScalar.  &lt;h3&gt;Getting a full result set with NpgsqlCommand.ExecuteReader() method and  NpgsqlDataReader &lt;/h3&gt;  &lt;p&gt;There are several ways to return recordsets with Npgsql. When you&#39;d like to  pass a SQL statement as command text and access the results with a  memory-efficent DataReader, use the ExecuteReader() method of the NpgsqlCommand  object:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;   NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;   conn.Open();&lt;br /&gt;  &lt;br /&gt;   NpgsqlCommand command = new NpgsqlCommand(&quot;select * from tablea&quot;, conn);&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;   try&lt;br /&gt;   {&lt;br /&gt; NpgsqlDataReader dr = command.ExecuteReader();&lt;br /&gt; while(dr.Read())&lt;br /&gt; {&lt;br /&gt;   for (i = 0; i &lt; dr.FieldCount; i++)&lt;br /&gt;   {&lt;br /&gt;    Console.Write(&quot;{0} \t&quot;, dr[i]);&lt;br /&gt;   }&lt;br /&gt;   Console.WriteLine();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   finally&lt;br /&gt;   {&lt;br /&gt;     conn.Close();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; Note that you can &#39;daily chain&#39; select statements in a command object&#39;s  commandtext to retrieve more than one record set: &quot;select * from tablea; select  * from tableb&quot;  &lt;p&gt;&lt;span style=&quot;color:red;&quot;&gt;Warning: &lt;/span&gt;There is a known issue when calling  ExecuteReader and large tables. Currently Npgsql gets all data from table before  returning. If you are experiencing bad performance in such cases, you may need  to use a server cursor to page through rows. For that, you can use a code like  the following:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;       NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;  &lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;declare te cursor for select * from tablea;&quot;, _conn);&lt;br /&gt;      &lt;br /&gt;       command.ExecuteNonQuery();&lt;br /&gt;      &lt;br /&gt;       command.CommandText = &quot;fetch forward 3 in te;&quot;;&lt;br /&gt;      &lt;br /&gt;       NpgsqlDataReader dr = command.ExecuteReader();&lt;br /&gt;      &lt;br /&gt;      &lt;br /&gt;       while (dr.Read())&lt;br /&gt;       {&lt;br /&gt;           //work with your data here.&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       dr.Close();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       // get more three rows.&lt;br /&gt;&lt;br /&gt;       dr = command.ExecuteReader();&lt;br /&gt;&lt;br /&gt;       while (dr.Read())&lt;br /&gt;       {&lt;br /&gt;       //work with your data here.&lt;br /&gt;       }&lt;br /&gt;      &lt;br /&gt;       dr.Close();&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;We are working to do this automatically in the next version.&lt;/p&gt;  &lt;h3&gt;Using parameters in a query &lt;/h3&gt;  &lt;p&gt;Parameters let you dynamcially insert values into SQL queries at run-time.  Generally speaking, parameter binding is the best way to build dynamic SQL  statements in your client code. Other approaches, such as basic string  concatenation, are less robust and can be vulerable to SQL injection attacks. To  add parameters to your SQL query string, prefix the paramter name with &quot;:&quot;. The  example below uses a parameter named value1 (see &quot;:value1&quot;).&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;   NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;   conn.Open();&lt;br /&gt;  &lt;br /&gt;   // Declare the parameter in the query string&lt;br /&gt;   NpgsqlCommand command = new NpgsqlCommand(&quot;select * from tablea where column1 = :value1&quot;, conn);&lt;br /&gt;  &lt;br /&gt;   // Now add the parameter to the parameter collection of the command specifying its type.&lt;br /&gt;   command.Parameters.Add(new NpgsqlParameter(&quot;value1&quot;, DbType.Int32));&lt;br /&gt;&lt;br /&gt;   // Now, add a value to it and later execute the command as usual.&lt;br /&gt;   command.Parameters[0].Value = 4;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;   try&lt;br /&gt;   {&lt;br /&gt; NpgsqlDataReader dr = command.ExecuteReader();&lt;br /&gt; while(dr.Read())&lt;br /&gt; {&lt;br /&gt;   for (i = 0; i &lt; dr.FieldCount; i++)&lt;br /&gt;   {&lt;br /&gt;    Console.Write(&quot;{0} \t&quot;, dr[i]);&lt;br /&gt;   }&lt;br /&gt;   Console.WriteLine();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   finally&lt;br /&gt;   {&lt;br /&gt;     conn.Close();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; You can also send a parameterized query to the server using  NpgsqlParamenter and NpgsqlParamenterCollection objects.) This code assumes a  table called &quot;tablea&quot; with at least one column named &quot;column1&quot; of type int4.  &lt;h3&gt;Using prepared statements&lt;/h3&gt;  &lt;p&gt;The Prepare method lets you optimize the performance of frequently used  queries. Prepare() basically &quot;caches&quot; the query plan so that it&#39;s used in  subsequent calls. (Note that this feature is only available in server 7.3+  versions. If you call it in a server which doesn&#39;t support it, Npgsql will  silently ignore it.) Simply call the Prepare() method of the NpgsqlCommand  before query execution:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;   NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;   conn.Open();&lt;br /&gt;  &lt;br /&gt;   // Declare the parameter in the query string&lt;br /&gt;   NpgsqlCommand command = new NpgsqlCommand(&quot;select * from tablea where column1 = :column1&quot;, conn);&lt;br /&gt;  &lt;br /&gt;   // Now add the parameter to the parameter collection of the command specifying its type.&lt;br /&gt;   command.Parameters.Add(new NpgsqlParameter(&quot;column1&quot;, DbType.Int32);&lt;br /&gt;&lt;br /&gt;   // Now, prepare the statement.&lt;br /&gt;   command.Prepare();&lt;br /&gt;&lt;br /&gt;   // Now, add a value to it and later execute the command as usual.&lt;br /&gt;   command.Parameters[0].Value = 4;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;   try&lt;br /&gt;   {&lt;br /&gt; NpgsqlDataReader dr = command.ExecuteReader();&lt;br /&gt; while(dr.Read())&lt;br /&gt; {&lt;br /&gt;   for (i = 0; i &lt; dr.FieldCount; i++)&lt;br /&gt;   {&lt;br /&gt;    Console.Write(&quot;{0} \t&quot;, dr[i]);&lt;br /&gt;   }&lt;br /&gt;   Console.WriteLine();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   finally&lt;br /&gt;   {&lt;br /&gt;     conn.Close();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; This code assumes a table called &quot;tablea&quot; with at least one column named  &quot;column1&quot; of type int4.  &lt;h3&gt;Function calling&lt;/h3&gt;  &lt;p&gt;To call a function, set the CommandType property of the NpgsqlCommand object  to CommandType.StoredProcedure and pass the name of the function you want to  call as the query string (CommandText property).&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// This example uses a function called funcC() with the following definition:&lt;br /&gt;// create function funcC() returns int8 as &#39;&lt;br /&gt;// select count(*) from tablea;&lt;br /&gt;// &#39; language &#39;sql&#39;;&lt;br /&gt;&lt;br /&gt;// Note that the return type of select count(*) changed from int4 to int8 in 7.3+ versions. To use this function&lt;br /&gt;// in a 7.2 server, change the return type from int8 to int4.&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;   NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;   conn.Open();&lt;br /&gt;  &lt;br /&gt;    &lt;br /&gt;   try&lt;br /&gt;   {&lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;funcC&quot;, conn);&lt;br /&gt;       command.CommandType = CommandType.StoredProcedure;&lt;br /&gt;      &lt;br /&gt;       Object result = command.ExecuteScalar();&lt;br /&gt;   &lt;br /&gt;       Console.WriteLine(result);&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   finally&lt;br /&gt;   {&lt;br /&gt;     conn.Close();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;Adding parameters to a PostgreSQL function is similar to our previous  examples. However, when specifying the CommandText string, you can exclude  parameter names. Use only the function name:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// This example uses a function called funcC with the following definition:&lt;br /&gt;// create function funcC(int4) returns int8 as &#39;&lt;br /&gt;// select count(*) from tablea where field_int4 = $1;&lt;br /&gt;// &#39; language &#39;sql&#39;;&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;   NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;   conn.Open();&lt;br /&gt;  &lt;br /&gt;    &lt;br /&gt;   try&lt;br /&gt;   {&lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;funcC&quot;, conn);&lt;br /&gt;       command.CommandType = CommandType.StoredProcedure;&lt;br /&gt;      &lt;br /&gt;  command.Parameters.Add(new NpgsqlParameter());&lt;br /&gt;          &lt;br /&gt;  command.Parameters[0].DbType = DbType.Int32;&lt;br /&gt;  command.Parameters[0].Value = 4;&lt;br /&gt;  &lt;br /&gt;       Object result = command.ExecuteScalar();&lt;br /&gt;   &lt;br /&gt;       Console.WriteLine(result);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   finally&lt;br /&gt;   {&lt;br /&gt;     conn.Close();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;This code assumes a table called &quot;tablea&quot; with at least one field called  &quot;field_int4&quot; of type int4.  &lt;/p&gt; &lt;h3&gt;Getting full results in a DataSet object: Using refcursors&lt;/h3&gt;  &lt;p&gt;Refcursors are one of the most powerful ways to build functions in Postgres  that return large result sets to the client. Using refcursors, a single function  can return the results of multiple queries to the client in a single round-trip.  Most Npgsql developers will learn that refcursors are quite easy to use once you  grasp the basic syntax.&lt;/p&gt;  &lt;p&gt;This sample returns two result sets from a function using refcursors. With  Npgsql&#39;s solid refcursor support, you can get many result sets without having to  worry about the internal workings of the refcursor in Postgres.&lt;/p&gt; Consider the  following refcursor-based function: &lt;pre class=&quot;CodeBox&quot;&gt;CREATE OR REPLACE FUNCTION testrefcursor(int4) RETURNS SETOF refcursor AS&lt;br /&gt;&lt;br /&gt;&#39;DECLARE&lt;br /&gt; ref1 refcursor;&lt;br /&gt; ref2 refcursor;&lt;br /&gt; ref3 refcursor;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;OPEN ref1 FOR&lt;br /&gt;SELECT * FROM table1;&lt;br /&gt;RETURN NEXT ref1;&lt;br /&gt;&lt;br /&gt;OPEN ref2 FOR&lt;br /&gt;SELECT * FROM table2;&lt;br /&gt;RETURN next ref2;&lt;br /&gt;&lt;br /&gt;OPEN ref3 FOR EXECUTE&lt;br /&gt;&#39;SELECT * FROM table3 WHERE keyfield = &#39; || $1;&lt;br /&gt;RETURN next ref3;&lt;br /&gt;&lt;br /&gt;RETURN;&lt;br /&gt;END;&#39;&lt;br /&gt;LANGUAGE plpgsql;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;This function returns the full results of three select statements. Notice  that the last select statement is dynamically created on the server.&lt;/p&gt;  &lt;p&gt;Now, to call these function and retrieve the data using a DataReader, you  should use the following code:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;using NpgsqlTypes;&lt;br /&gt;&lt;br /&gt;public class c&lt;br /&gt;{&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;              &lt;br /&gt;       NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Initial Catalog=eeeeee;User id=npgsql_tests;password=npgsql_tests;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;&lt;br /&gt;       NpgsqlTransaction t = conn.BeginTransaction();         &lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;testrefcursor&quot;, conn);&lt;br /&gt;       command.CommandType = CommandType.StoredProcedure;&lt;br /&gt;      &lt;br /&gt;       NpgsqlDataReader dr = command.ExecuteReader();&lt;br /&gt;  &lt;br /&gt;       while(dr.Read())&lt;br /&gt;       {&lt;br /&gt;      &lt;br /&gt;           Console.WriteLine(dr.GetValue(0));&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       dr.NextResult();&lt;br /&gt;  &lt;br /&gt;       while(dr.Read())&lt;br /&gt;       {&lt;br /&gt;  &lt;br /&gt;           Console.WriteLine(dr.GetValue(0));&lt;br /&gt;       }&lt;br /&gt;       dr.Close();&lt;br /&gt;       t.Commit();&lt;br /&gt;       conn.Close();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; Alternatively, you can retrieve the results into a DataSet object:  &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;using NpgsqlTypes;&lt;br /&gt;&lt;br /&gt;public class c&lt;br /&gt;{&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;       DataSet myDS;&lt;br /&gt;       NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Initial Catalog=eeeeee;User id=npgsql_tests;password=npgsql_tests;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;&lt;br /&gt;       NpgsqlTransaction t = conn.BeginTransaction();         &lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;testrefcursor&quot;, conn);&lt;br /&gt;       command.CommandType = CommandType.StoredProcedure;&lt;br /&gt;      &lt;br /&gt;       con.Open();&lt;br /&gt;       NpgsqlDataAdapter da = new NpgsqlDataAdapter(command);&lt;br /&gt;       da.Fill(myDS);&lt;br /&gt;&lt;br /&gt;       t.Commit();&lt;br /&gt;       conn.Close();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;That&#39;s it!. One last thing worth noting is that &lt;span style=&quot;color:red;&quot;&gt;you have to  use a transaction&lt;/span&gt; in order for this to work. This is necessary to prevent  cursors returned by refcursor function from closing after the implicity  transaction is finished (just after you do the function call).&lt;/p&gt;  &lt;p&gt;If you have parameters in your function, &lt;span style=&quot;color:red;&quot;&gt;assign only the  function name &lt;/span&gt;to the CommandText property and add parameters to the  NpgsqlCommand.Parameters collection as usual. Npgsql will take care of binding  your parameters correctly. &lt;/p&gt;  &lt;h3&gt;Using output parameters in a query &lt;/h3&gt;  &lt;p&gt;Output parameters can be used with Npgsql. Note that Npgsql &quot;simulates&quot;  output parameter by parsing the first result set from the execution of a query  and translating it to output parameters value. This can be done in two ways:  mapped or not. A mapped parsing, tries to match the column name returned by  resultset into a parameter with the same name. If a match is found, only the  output parameters which has a match will be updated. If a map is not found, the  output parameters are updated based on the order they were added to command  parameters collection. This mapping is automatic. When parsing resultset, Npgsql  tries to find a match. &lt;b&gt;Both Output and InputOutput parameter directions are  supported&lt;/b&gt;.&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;       NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;      &lt;br /&gt;       // Send a query to backend.&lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;select * from tablea where column1 = 2&quot;, conn);&lt;br /&gt;      &lt;br /&gt;       // Now declare an output parameter to receive the first column of the tablea.&lt;br /&gt;      &lt;br /&gt;       NpgsqlParameter firstColumn = new NpgsqlParameter(&quot;firstcolumn&quot;, NpgsqlDbType.Integer);&lt;br /&gt;       firstColumn.Direction = ParameterDirection.Output;&lt;br /&gt;      &lt;br /&gt;       command.Parameters.Add(firstColumn);&lt;br /&gt;  &lt;br /&gt;          &lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;           command.ExecuteNonQuery();&lt;br /&gt;          &lt;br /&gt;           // Now, the firstcolumn parameter will have the value of the first column of the resultset.&lt;br /&gt;           Console.WriteLine(firstColumn.Value);&lt;br /&gt;          &lt;br /&gt;  &lt;br /&gt;       }&lt;br /&gt;      &lt;br /&gt;       finally&lt;br /&gt;       {&lt;br /&gt;           conn.Close();&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Working with .NET Datasets &lt;/h3&gt;  &lt;p&gt;Npgsql lets you propogate changes to a .NET DataSet object back to the  database. The example below demonstrates the insertion of a record into a  DataSet, followed by a call to update the associated database:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;// This method expects the following table in the backend:&lt;br /&gt;//&lt;br /&gt;// create table tableb(field_int2 int2, field_timestamp timestamp, field_numeric numeric);&lt;br /&gt;//&lt;br /&gt;// &lt;br /&gt;void AddWithDataSet(NpgsqlConnection conn)&lt;br /&gt;{ &lt;br /&gt; conn.Open();&lt;br /&gt;   &lt;br /&gt; DataSet ds = new DataSet();&lt;br /&gt;&lt;br /&gt; NpgsqlDataAdapter da = new NpgsqlDataAdapter(&quot;select * from tableb&quot;, conn);&lt;br /&gt; &lt;br /&gt; da.InsertCommand = new NpgsqlCommand(&quot;insert into tableb(field_int2, field_timestamp, field_numeric) &quot; +&lt;br /&gt;       &quot; values (:a, :b, :c)&quot;, conn);&lt;br /&gt;   &lt;br /&gt; da.InsertCommand.Parameters.Add(new NpgsqlParameter(&quot;a&quot;, DbType.Int16));&lt;br /&gt; &lt;br /&gt; da.InsertCommand.Parameters.Add(new NpgsqlParameter(&quot;b&quot;, DbType.DateTime));&lt;br /&gt;   &lt;br /&gt; da.InsertCommand.Parameters.Add(new NpgsqlParameter(&quot;c&quot;, DbType.Decimal));&lt;br /&gt; &lt;br /&gt; da.InsertCommand.Parameters[0].Direction = ParameterDirection.Input;&lt;br /&gt; da.InsertCommand.Parameters[1].Direction = ParameterDirection.Input;&lt;br /&gt; da.InsertCommand.Parameters[2].Direction = ParameterDirection.Input;&lt;br /&gt; &lt;br /&gt; da.InsertCommand.Parameters[0].SourceColumn = &quot;field_int2&quot;;&lt;br /&gt; da.InsertCommand.Parameters[1].SourceColumn = &quot;field_timestamp&quot;;&lt;br /&gt; da.InsertCommand.Parameters[2].SourceColumn = &quot;field_numeric&quot;;&lt;br /&gt; &lt;br /&gt; da.Fill(ds);&lt;br /&gt; &lt;br /&gt; DataTable dt = ds.Tables[0];&lt;br /&gt; &lt;br /&gt; DataRow dr = dt.NewRow();&lt;br /&gt; dr[&quot;field_int2&quot;] = 4;&lt;br /&gt; dr[&quot;field_timestamp&quot;] = new DateTime(2003, 03, 03, 14, 0, 0);&lt;br /&gt; dr[&quot;field_numeric&quot;] = 7.3M;&lt;br /&gt;   &lt;br /&gt; dt.Rows.Add(dr);&lt;br /&gt;   &lt;br /&gt; DataSet ds2 = ds.GetChanges();&lt;br /&gt; &lt;br /&gt; da.Update(ds2);&lt;br /&gt; &lt;br /&gt; ds.Merge(ds2);&lt;br /&gt; ds.AcceptChanges();&lt;br /&gt;}&lt;br /&gt;  &lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Working with strongly typed datasets &lt;/h3&gt;  &lt;p&gt;This example demonstrates the use of a strongly typed dataset generated by  XSD. To start, we need an XSD file specifing the appropiate schema. You can  generate this file by hand, or you can use an XSD tool to generate it for you.  In order to let NpgsqlDataAdapter generate XSD, you need to suppy it with an XML  file; the XML file allows the inference of an XML schema. &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;public void GenerateXmlFromDataSet(NpgsqlConnection conn)&lt;br /&gt;{&lt;br /&gt; conn.Open();&lt;br /&gt;   &lt;br /&gt;      &lt;br /&gt; NpgsqlDataAdapter da = new NpgsqlDataAdapter(&quot;select * from tablea&quot;, conn);&lt;br /&gt;  &lt;br /&gt; DataSet ds = new DataSet();&lt;br /&gt;   &lt;br /&gt; da.Fill(ds);&lt;br /&gt;   &lt;br /&gt; ds.WriteXml(&quot;StrongDataSetFeed.xml&quot;);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;The example code results in a file which looks similar to:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;&lt;?xml version=&quot;1.0&quot; standalone=&quot;yes&quot;?&gt;&lt;br /&gt;&lt;newdataset&gt;&lt;br /&gt; &lt;table&gt;&lt;br /&gt;   &lt;field_serial&gt;1&lt;/field_serial&gt;&lt;br /&gt;   &lt;field_text&gt;Random text&lt;/field_text&gt;&lt;br /&gt; &lt;/table&gt;&lt;br /&gt; &lt;table&gt;&lt;br /&gt;   &lt;field_serial&gt;2&lt;/field_serial&gt;&lt;br /&gt;   &lt;field_int4&gt;4&lt;/field_int4&gt;&lt;br /&gt; &lt;/table&gt;&lt;br /&gt; &lt;table&gt;&lt;br /&gt;   &lt;field_serial&gt;3&lt;/field_serial&gt;&lt;br /&gt;   &lt;field_int8&gt;8&lt;/field_int8&gt;&lt;br /&gt; &lt;/table&gt;&lt;br /&gt; &lt;table&gt;&lt;br /&gt;   &lt;field_serial&gt;4&lt;/field_serial&gt;&lt;br /&gt;   &lt;field_bool&gt;true&lt;/field_bool&gt;&lt;br /&gt; &lt;/table&gt;&lt;br /&gt; &lt;table&gt;&lt;br /&gt;   &lt;field_serial&gt;5&lt;/field_serial&gt;&lt;br /&gt;   &lt;field_text&gt;Text with &#39; single quote&lt;/field_text&gt;&lt;br /&gt; &lt;/table&gt;&lt;br /&gt;&lt;/newdataset&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;The following command uses the file to generate XSD:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;xsd StrongDataSetFeed.xml&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;XSD will produce an XML schema in which all types are specified as string. As  a consequence, we need to change the XSD to specify the correct types, resulting  in an XSD file similar to:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;br /&gt;&lt;xs:schema id=&quot;NewDataSet&quot; xmlns=&quot;&quot; xs=&quot;http://www.w3.org/2001/XMLSchema&quot; msdata=&quot;urn:schemas-microsoft-com:xml-msdata&quot;&gt;&lt;br /&gt; &lt;xs:element name=&quot;NewDataSet&quot; isdataset=&quot;true&quot; locale=&quot;pt-BR&quot;&gt;&lt;br /&gt;   &lt;xs:complextype&gt;&lt;br /&gt;     &lt;xs:choice maxoccurs=&quot;unbounded&quot;&gt;&lt;br /&gt;       &lt;xs:element name=&quot;Table&quot;&gt;&lt;br /&gt;         &lt;xs:complextype&gt;&lt;br /&gt;           &lt;xs:sequence&gt;&lt;br /&gt;             &lt;xs:element name=&quot;field_serial&quot; type=&quot;xs:int&quot; minoccurs=&quot;0&quot;&gt;&lt;br /&gt;             &lt;xs:element name=&quot;field_text&quot; type=&quot;xs:string&quot; minoccurs=&quot;0&quot;&gt;&lt;br /&gt;             &lt;xs:element name=&quot;field_int4&quot; type=&quot;xs:int&quot; minoccurs=&quot;0&quot;&gt;&lt;br /&gt;             &lt;xs:element name=&quot;field_int8&quot; type=&quot;xs:long&quot; minoccurs=&quot;0&quot;&gt;&lt;br /&gt;             &lt;xs:element name=&quot;field_bool&quot; type=&quot;xs:boolean&quot; minoccurs=&quot;0&quot;&gt;&lt;br /&gt;           &lt;/xs:sequence&gt;&lt;br /&gt;         &lt;/xs:complexType&gt;&lt;br /&gt;       &lt;/xs:element&gt;&lt;br /&gt;     &lt;/xs:choice&gt;&lt;br /&gt;   &lt;/xs:complexType&gt;&lt;br /&gt; &lt;/xs:element&gt;&lt;br /&gt;&lt;/xs:schema&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;Given the above file, the following command generates a strongly typed  dataset:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;xsd StrongDataSetFeed.xsd /dataset&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;This command generates a file that compiles into an assembly for the strongly  typed dataset. It&#39;s used in the example below:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class t&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;  NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;&lt;br /&gt;  conn.Open();&lt;br /&gt;  &lt;br /&gt;  NpgsqlDataAdapter da = new NpgsqlDataAdapter(&quot;Select * from tablea&quot;, conn);&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;  NewDataSet n = new NewDataSet();&lt;br /&gt;&lt;br /&gt;  da.Fill(n);&lt;br /&gt;&lt;br /&gt;  foreach (NewDataSet._TableRow tr in n._Table)&lt;br /&gt;  {&lt;br /&gt;   Console.WriteLine(tr.field_serial);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Working with binary data and bytea datatype&lt;/h3&gt;  &lt;p&gt;This sample takes a filename as an argument, inserts its contents into a  table called &quot;tableByteA&quot;. The table contains a field named &quot;field_bytea&quot; of  type bytea and a field named &quot;field_serial&quot; of type serial. Next, it retrieves  the field contents and writes a new file with the suffix &quot;database&quot;.&lt;/p&gt;  &lt;p&gt;table schema: create table tableBytea (field_serial serial, field_bytea  bytea) &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class t&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;  //NpgsqlEventLog.Level = LogLevel.Debug;&lt;br /&gt;  //NpgsqlEventLog.LogName = &quot;NpgsqlTests.LogFile&quot;;&lt;br /&gt;  NpgsqlConnection conn = new NpgsqlConnection(&quot;server=localhost;user id=npgsql_tests;password=npgsql_tests&quot;);&lt;br /&gt;  conn.Open();&lt;br /&gt;&lt;br /&gt;  FileStream fs = new FileStream(args[0], FileMode.Open, FileAccess.Read);&lt;br /&gt;&lt;br /&gt;  BinaryReader br = new BinaryReader(new BufferedStream(fs));&lt;br /&gt;&lt;br /&gt;  Byte[] bytes = br.ReadBytes((Int32)fs.Length);&lt;br /&gt;  &lt;br /&gt;  Console.WriteLine(fs.Length);&lt;br /&gt;&lt;br /&gt;  br.Close();&lt;br /&gt;  fs.Close();&lt;br /&gt;    &lt;br /&gt;  NpgsqlCommand command = new NpgsqlCommand(&quot;insert into tableBytea(field_bytea) values(:bytesData)&quot;, conn);&lt;br /&gt;  &lt;br /&gt;  NpgsqlParameter param = new NpgsqlParameter(&quot;:bytesData&quot;, DbType.Binary);&lt;br /&gt;&lt;br /&gt;  param.Value = bytes;&lt;br /&gt;  &lt;br /&gt;  command.Parameters.Add(param);&lt;br /&gt;  command.ExecuteNonQuery();&lt;br /&gt;  command = new NpgsqlCommand(&quot;select field_bytea from tableBytea where field_serial = (select max(select field_serial) from tableBytea);&quot;, conn);&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;  Byte[] result = (Byte[])command.ExecuteScalar();&lt;br /&gt;  fs = new FileStream(args[0] + &quot;database&quot;, FileMode.Create, FileAccess.Write);&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;  BinaryWriter bw = new BinaryWriter(new BufferedStream(fs));&lt;br /&gt;&lt;br /&gt;  bw.Write(result);&lt;br /&gt;&lt;br /&gt;  bw.Flush();&lt;br /&gt;&lt;br /&gt;  fs.Close();&lt;br /&gt;  bw.Close();  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  conn.Close();&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Working with large object support&lt;/h3&gt;  &lt;p&gt;This sample is nearly identical to the bytea code above. It stores the  retrieved file in Postgresql, and then later removes it. As with the bytea  sample, it writes a file with a &quot;database&quot; suffix. &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;using NpgsqlTypes;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;public class c&lt;br /&gt;{&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;       NpgsqlConnection newconn = new NpgsqlConnection(&quot;server=localhost;user id=npgsql_tests;password=npgsql_tests&quot;);&lt;br /&gt;&lt;br /&gt;       newcon.Open();&lt;br /&gt;       NpgsqlTransaction t = newcon.BeginTransaction();&lt;br /&gt;       LargeObjectManager lbm = new LargeObjectManager(newcon);&lt;br /&gt;&lt;br /&gt;       int noid = lbm.Create(LargeObjectManager.READWRITE);&lt;br /&gt;       LargeObject lo =  lbm.Open(noid,LargeObjectManager.READWRITE);&lt;br /&gt;&lt;br /&gt;       FileStream fs = File.OpenRead(args[0]);&lt;br /&gt;&lt;br /&gt;       byte[] buf = new byte[fs.Length];&lt;br /&gt;       fs.Read(buf,0,(int)fs.Length);&lt;br /&gt;&lt;br /&gt;       lo.Write(buf);&lt;br /&gt;       lo.Close();&lt;br /&gt;       t.Commit();&lt;br /&gt;      &lt;br /&gt;      &lt;br /&gt;       t = newcon.BeginTransaction();&lt;br /&gt;      &lt;br /&gt;       lo =  lbm.Open(noid,LargeObjectManager.READWRITE);&lt;br /&gt;      &lt;br /&gt;       FileStream fsout = File.OpenWrite(args[0] + &quot;database&quot;);&lt;br /&gt;      &lt;br /&gt;       buf = lo.Read(lo.Size());&lt;br /&gt;      &lt;br /&gt;       fsout.Write(buf, 0, (int)lo.Size());&lt;br /&gt;       fsout.Flush();&lt;br /&gt;       fsout.Close();&lt;br /&gt;       lo.Close();&lt;br /&gt;       t.Commit();&lt;br /&gt;      &lt;br /&gt;      &lt;br /&gt;       DeleteLargeObject(noid);&lt;br /&gt;      &lt;br /&gt;       Console.WriteLine(&quot;noid: {0}&quot;, noid);&lt;br /&gt;       newcon.Close();&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   public static void DeleteLargeObject(Int32 noid)&lt;br /&gt;   {&lt;br /&gt;       NpgsqlConnection conn = new NpgsqlConnection(&quot;server=localhost;user id=npgsql_tests;password=npgsql_tests&quot;);&lt;br /&gt;&lt;br /&gt;       newcon.Open();&lt;br /&gt;       NpgsqlTransaction t = newcon.BeginTransaction();&lt;br /&gt;       LargeObjectManager lbm = new LargeObjectManager(newcon);&lt;br /&gt;       lbm.Delete(noid);&lt;br /&gt;      &lt;br /&gt;       t.Commit();&lt;br /&gt;      &lt;br /&gt;       newcon.Close();&lt;br /&gt;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;Another example, contributed by Mirek (mirek at mascort dot com dot pl), uses  large object support to get an image from the database and display it in a form  on the client. &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using Npgsql;&lt;br /&gt;using NpgsqlTypes;&lt;br /&gt;using System.Drawing;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;//metod whos take picture oid  from database&lt;br /&gt;&lt;br /&gt;public int takeOID(int id)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   //it&#39;s a metod whos connect  to database and return picture oid&lt;br /&gt;  &lt;br /&gt;   BazySQL pir = new BazySQL(Login.DaneUzera[8]);&lt;br /&gt;  &lt;br /&gt;   string pytanko = String.Format(&quot;select rysunek from k_rysunki where idtowaru = &quot; + idtowaru.ToString());&lt;br /&gt;  &lt;br /&gt;   string[] wartosci = pir.OddajSelectArray(pytanko);&lt;br /&gt;  &lt;br /&gt;   int liczba = int.Parse(wartosci[0].ToString());&lt;br /&gt;  &lt;br /&gt;   return liczba;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//take a picture from database and convert to Image type&lt;br /&gt;&lt;br /&gt;public Image pobierzRysunek(int idtowaru)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   NpgsqlConnection Polacz = new NpgsqlConnection();&lt;br /&gt;  &lt;br /&gt;   Polacz.ConnectionString = Login.DaneUzera[8].ToString();  //its metod whos return connection string&lt;br /&gt;  &lt;br /&gt;   Polacz.Open();&lt;br /&gt;  &lt;br /&gt;   NpgsqlTransaction t = Polacz.BeginTransaction();&lt;br /&gt;  &lt;br /&gt;   LargeObjectManager lbm = new LargeObjectManager(Polacz);&lt;br /&gt;  &lt;br /&gt;   LargeObject lo = lbm.Open(takeOID(idtowaru),LargeObjectManager.READWRITE); //take picture oid from metod takeOID&lt;br /&gt;  &lt;br /&gt;   byte[] buf = new byte[lo.Size()];&lt;br /&gt;  &lt;br /&gt;   buf = lo.Read(lo.Size());&lt;br /&gt;  &lt;br /&gt;   MemoryStream ms = new MemoryStream();&lt;br /&gt;  &lt;br /&gt;   ms.Write(buf,0,lo.Size());&lt;br /&gt;  &lt;br /&gt;   lo.Close();&lt;br /&gt;  &lt;br /&gt;   t.Commit();&lt;br /&gt;  &lt;br /&gt;   Polacz.Close();&lt;br /&gt;  &lt;br /&gt;   Polacz.Dispose();&lt;br /&gt;  &lt;br /&gt;   Image zdjecie = Image.FromStream(ms);&lt;br /&gt;  &lt;br /&gt;   return zdjecie;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//next I just use this metod&lt;br /&gt;&lt;br /&gt;pictureBox1.Image = Image pobierzRysunek(1);&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Retrieving last inserted id on a table with serial values&lt;/h3&gt;  &lt;p&gt;This example was contributed by Josh Cooley when answering an &lt;a href=&quot;http://pgfoundry.org/forum/forum.php?thread_id=943&amp;amp;forum_id=519&quot;&gt;user  question&lt;/a&gt; on Npgsql Forums. This code assumes you have the following table  and function in your database:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt; create table test_seq (field_serial serial, test_text text);&lt;br /&gt;&lt;br /&gt;CREATE OR REPLACE FUNCTION ins_seq(&quot;varchar&quot;)&lt;br /&gt;       RETURNS test_seq AS&lt;br /&gt;       &#39;insert into test_seq (test_text) values ($1);&lt;br /&gt;       select * from test_seq where test_text = $1&#39;&lt;br /&gt;       LANGUAGE &#39;sql&#39; VOLATILE;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;And this is the code:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;using NpgsqlTypes;&lt;br /&gt;&lt;br /&gt;public class c&lt;br /&gt;{&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;       //NpgsqlEventLog.Level = LogLevel.Debug;&lt;br /&gt;       //NpgsqlEventLog.LogName = &quot;NpgsqlTests.LogFile&quot;;&lt;br /&gt;       //NpgsqlEventLog.EchoMessages = true;&lt;br /&gt;&lt;br /&gt;       NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;&quot;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       using (NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(&quot;select * from test_seq&quot;, conn))&lt;br /&gt;       {&lt;br /&gt;          &lt;br /&gt;           DataTable table = new DataTable();&lt;br /&gt;           adapter.Fill(table);&lt;br /&gt;           adapter.InsertCommand = new NpgsqlCommand(&quot;ins_seq&quot;, adapter.SelectCommand.Connection);&lt;br /&gt;           adapter.InsertCommand.Parameters.Add(&quot;foo&quot;, NpgsqlTypes.NpgsqlDbType.Varchar, 100, &quot;test_text&quot;);&lt;br /&gt;           adapter.InsertCommand.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;           DataRow row = table.NewRow();&lt;br /&gt;           row[&quot;test_text&quot;] = &quot;asdfqwert&quot;;&lt;br /&gt;           table.Rows.Add(row);&lt;br /&gt;           adapter.Update(table);&lt;br /&gt;&lt;br /&gt;           foreach (DataRow rowItem in table.Rows)&lt;br /&gt;           {&lt;br /&gt;               Console.WriteLine(&quot;key {0}, value {1}&quot;, rowItem[0], rowItem[1]);&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           Console.ReadLine();&lt;br /&gt;       }&lt;br /&gt;      &lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Cancelling a command in progress &lt;/h3&gt;  &lt;p&gt;Npgsql is able to ask the server to cancel commands in progress. To do this,  call the NpgsqlCommand&#39;s Cancel method. Note that another thread must handle the  request as the main thread will be blocked waiting for command to finish. Also,  the main thread will raise an exception as a result of user cancellation. (The  error code is 57014.) See the following code which demonstrates the  technique:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;using NpgsqlTypes;&lt;br /&gt;using System.Threading;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class c&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   // This method expects the following table in the backend:&lt;br /&gt;   //&lt;br /&gt;   /*      CREATE OR REPLACE FUNCTION funcwaits() returns integer as&lt;br /&gt;   &#39;&lt;br /&gt;   declare t integer;&lt;br /&gt;   begin&lt;br /&gt;  &lt;br /&gt;   t := 0;&lt;br /&gt;  &lt;br /&gt;   while t &lt; 1000000 loop&lt;br /&gt;   t := t + 1;&lt;br /&gt;   end loop;&lt;br /&gt;  &lt;br /&gt;   return t;&lt;br /&gt;   end;&lt;br /&gt;   &#39;&lt;br /&gt;   */&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   static NpgsqlConnection conn = null;&lt;br /&gt;   static NpgsqlCommand command = null;&lt;br /&gt;&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;       //NpgsqlEventLog.Level = LogLevel.Debug;&lt;br /&gt;       //NpgsqlEventLog.LogName = &quot;NpgsqlTests.LogFile&quot;;&lt;br /&gt;       //NpgsqlEventLog.EchoMessages = true;&lt;br /&gt;&lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;&lt;br /&gt;       conn = new NpgsqlConnection(&quot;Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;&lt;br /&gt;       NpgsqlCommand d = new NpgsqlCommand();&lt;br /&gt;&lt;br /&gt;       Thread t = new Thread(new ThreadStart(CancelRequest));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;       command = new NpgsqlCommand(&quot;select * from funcwaits()&quot;, conn);&lt;br /&gt;&lt;br /&gt;       Console.WriteLine(&quot;Cancelling command...&quot;);&lt;br /&gt;       t.Start();&lt;br /&gt;&lt;br /&gt;       Console.WriteLine(command.ExecuteScalar());&lt;br /&gt;       conn.Close();&lt;br /&gt;       }&lt;br /&gt;       catch(NpgsqlException e)&lt;br /&gt;       {&lt;br /&gt;               if (e.Code == &quot;57014&quot;)&lt;br /&gt;                       Console.WriteLine(&quot;Command was cancelled&quot;);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public static void CancelRequest()&lt;br /&gt;   {&lt;br /&gt;       command.Cancel();&lt;br /&gt;       Console.WriteLine(&quot;command cancelled&quot;);&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Working with Notifications&lt;/h3&gt;  &lt;p&gt;Npgsql allows user to receive events based on notifications sent by a server.  There are two ways to receive notications with Npgsql: asynchronously or  synchronously. Synchronous notification is only supported by Npgsql 1.0 and  above.&lt;/p&gt;  &lt;h4&gt;Asynchronous notifications &lt;/h4&gt; This is the default notification mechanism  used in Npgsql. It is called asynchronous because Npgsql doesn&#39;t receive a  notification upon execution of the event which generated it on the server.  Npgsql receives the notification on the next instance of client interaction with  the server. This interaction actually occurs when Npgsql sends a subsequent  command to the server- which might consist of a few seconds to many hours later.  With this in mind, most users will need to actively poll the server in order to  recieve notifications in a timely matter. One approach involves polling via  empty commands such as &quot;;&quot;  &lt;h4&gt;Synchronous notifications &lt;/h4&gt; Starting with Npgsql 1.0, there is support  for synchronous notifications. When working in this mode, Npgsql is able to  receive a notificaton upon its instantiation and deliver it to client. All this  is done without any additional interaction between the client and server (as  described above). The code to receive the notification is the same for both  modes:  &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;using NpgsqlTypes;&lt;br /&gt;using System.Threading;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class c&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;       conn = new NpgsqlConnection(&quot;Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;  &lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;listen notifytest;&quot;, conn);&lt;br /&gt;       command.ExecuteNonQuery();&lt;br /&gt;      &lt;br /&gt;       conn.Notification += new NotificationEventHandler(NotificationSupportHelper);&lt;br /&gt;      &lt;br /&gt;      &lt;br /&gt;       command = new NpgsqlCommand(&quot;notify notifytest;&quot;, _conn);&lt;br /&gt;       command.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;       Console.ReadLine();  // To prevent program termination before notification is handled.&lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   private void NotificationSupportHelper(Object sender, NpgsqlNotificationEventArgs args)&lt;br /&gt;   {&lt;br /&gt;       // process notification here.&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;This code registers to listen for a notification and raises the notification.  It will be delivered to the NotificationSupportHelper method.&lt;/p&gt;  &lt;h3&gt;Fast bulk data copy into a table&lt;/h3&gt;  &lt;p&gt;Batched inserts can be time consuming with large amounts of data. PostgreSQL  provides an alternative, much faster method of importing raw data. Its syntax  and input format options are already explained in &lt;a href=&quot;http://www.postgresql.org/docs/8.2/interactive/sql-copy.html&quot;&gt;PostgreSQL  COPY documentation&lt;/a&gt;. To copy data from client-side you need to use the  &lt;code&gt;FROM STDIN&lt;/code&gt; option.&lt;/p&gt;  &lt;p&gt;When feeding straight to COPY IN operation, &lt;b&gt;you have to provide data using  the same encoding as the server uses.&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The simplest method is to provide a readable file handle to the CopyIn  operation constructor. Upon start, the copy in operation will read whole  contents of given stream and push them to the server. (Refer to COPY statement  documentation for different input formats!)&lt;/p&gt;  &lt;ol&gt; &lt;li&gt;See to it that you set SyncNotification=true in your database connection    string. This is to catch any anomaly reports during import to prevent deadlock    between client and server network buffers.    &lt;/li&gt;&lt;li&gt;Create NpgsqCopyIn object with a stream providing the data to input into    database    &lt;/li&gt;&lt;li&gt;Call Start() to initiate copy operation. The operation is completed    immediately.    &lt;/li&gt;&lt;li&gt;If Start() throws an exception, call NpgsqlCopyIn.Cancel() to cancel an    ongoing operation and clear connection back to Ready For Query state.    Otherwise your &lt;b&gt;connection may stay in copy mode, unusable for anything    else&lt;/b&gt;. &lt;/li&gt; &lt;/ol&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public class CopyInExample&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;       conn = new NpgsqlConnection(&quot;Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;SyncNotification=true;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;&lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;COPY myCopyTestTable FROM STDIN&quot;, conn);&lt;br /&gt;       NpgsqlCopyIn cin = new NpgsqlCopyIn( command, conn, Console.OpenStandardInput() ); // expecting input in server encoding!&lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;           cin.Start();&lt;br /&gt;       }&lt;br /&gt;       catch(Exception e)&lt;br /&gt;       {&lt;br /&gt;           try&lt;br /&gt;           {&lt;br /&gt;               cin.Cancel(&quot;Undo copy&quot;);&lt;br /&gt;           }&lt;br /&gt;           catch(NpgsqlException e2)&lt;br /&gt;           {&lt;br /&gt;               // we should get an error in response to our cancel request:&lt;br /&gt;               if( ! (&quot;&quot;+e2).Contains(&quot;Undo copy&quot;) )&lt;br /&gt;               {&lt;br /&gt;                   throw new Exception(&quot;Failed to cancel copy: &quot; + e2 + &quot; upon failure: &quot; + e);&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;           throw e;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;If you wish to provide the data from inside your application, you can use a  normal writable stream:&lt;/p&gt;  &lt;ol&gt; &lt;li&gt;See to it that you set SyncNotification=true in your database connection    string. This is to catch any anomaly reports during import to prevent deadlock    between client and server network buffers.    &lt;/li&gt;&lt;li&gt;Create NpgsqCopyIn object without specifying a stream    &lt;/li&gt;&lt;li&gt;Call Start() to initiate copy operation    &lt;/li&gt;&lt;li&gt;Write your data in correct format and encoding into    NpgsqlCopyIn.CopyStream    &lt;/li&gt;&lt;li&gt;&lt;b&gt;During the operation the connection can not be used for anything    else.&lt;/b&gt;    &lt;/li&gt;&lt;li&gt;Call CopyStream.Close() or NpgsqlCopyIn.End() to complete writing    &lt;/li&gt;&lt;li&gt;To cancel an ongoing operation and clear connection back to Ready For    Query state call NpgsqlCopyIn.Cancel().    &lt;/li&gt;&lt;li&gt;Upon failure call NpgsqlCopyIn.Cancel() to cancel an ongoing operation and    clear connection back to Ready For Query state. Otherwise your &lt;b&gt;connection    may stay in copy mode, unusable for anything else&lt;/b&gt;. &lt;/li&gt; &lt;/ol&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public class CopyInExample&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;       conn = new NpgsqlConnection(&quot;Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;SyncNotification=true;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;&lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;COPY myCopyTestTable FROM STDIN&quot;, conn);&lt;br /&gt;       NpgsqlCopyIn cin = new NpgsqlCopyIn( command, conn );&lt;br /&gt;      &lt;br /&gt;       Stream inStream = Console.OpenStandardInput();&lt;br /&gt;       Encoding inEncoding = System.Text.Encoding.ASCII;&lt;br /&gt;       Encoding serverEncoding = System.Text.Encoding.BigEndianUnicode; // example assumption&lt;br /&gt;&lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;           cin.Start();&lt;br /&gt;           Stream copyInStream = cin.CopyStream;&lt;br /&gt;           byte[] buf = new byte[9];&lt;br /&gt;           int i;&lt;br /&gt;           while( (i = inStream.Read(buf,0,buf.Length)) &gt; 0 )&lt;br /&gt;           {&lt;br /&gt;               buf = System.Text.Convert( inEncoding, serverEncoding, buf, 0, i );&lt;br /&gt;               copyInStream.Write( buf, 0, i );&lt;br /&gt;           }&lt;br /&gt;           copyInStream.Close(); // or cin.End(), if you wish&lt;br /&gt;       }&lt;br /&gt;       catch(Exception e)&lt;br /&gt;       {&lt;br /&gt;           try&lt;br /&gt;           {&lt;br /&gt;               cin.Cancel(&quot;Undo copy&quot;); // Sends CopyFail to server&lt;br /&gt;           }&lt;br /&gt;           catch(Exception e2)&lt;br /&gt;           {&lt;br /&gt;               // we should get an error in response to our cancel request:&lt;br /&gt;               if( ! (&quot;&quot;+e2).Contains(&quot;Undo copy&quot;) )&lt;br /&gt;               {&lt;br /&gt;                   throw new Exception(&quot;Failed to cancel copy: &quot; + e2 + &quot; upon failure: &quot; + e);&lt;br /&gt;               }&lt;br /&gt;           }&lt;br /&gt;           throw e;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;Fast bulk data copy from a table or select&lt;/h3&gt;  &lt;p&gt;Even trivial selections of large data sets can become time consuming when  network is the bottleneck. PostgreSQL provides an alternative, much faster  method of exporting raw data. Its syntax and input format options are already  explained in &lt;a href=&quot;http://www.postgresql.org/docs/8.2/interactive/sql-copy.html&quot;&gt;PostgreSQL  COPY documentation&lt;/a&gt;. To copy data to client-side you need to use the &lt;code&gt;TO  STDOUT&lt;/code&gt; option.&lt;/p&gt;  &lt;p&gt;COPY OUT provides data &lt;b&gt;in server-side encoding.&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The simplest method is to provide a writable stream to the CopyOut operation  constructor. Upon start, the operation will then write everything coming down  from server right into that sink. (Refer to COPY statement documentation for  different output formats!)&lt;/p&gt;  &lt;ol&gt; &lt;li&gt;Create NpgsqCopyOut object with a stream for writing the output received    from database    &lt;/li&gt;&lt;li&gt;Call Start() to initiate copy operation. All requested data is written to    specified stream immediately.    &lt;/li&gt;&lt;li&gt;An ongoing operation may be cancelled by calling CopyStream.Close() or    NpgsqlCopyIn.End()    &lt;/li&gt;&lt;li&gt;Upon failure your &lt;b&gt;connection becomes unusable&lt;/b&gt; unless you cancel the    copy operation.    &lt;/li&gt;&lt;li&gt;If Start() throws an exception, cancel the ongoing operation. Otherwise    your &lt;b&gt;connection may stay in copy mode, unusable for anything else&lt;/b&gt;.  &lt;/li&gt; &lt;/ol&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public class CopyOutExample&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;       conn = new NpgsqlConnection(&quot;Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;&lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;COPY myCopyTestTable TO STDOUT&quot;, conn);&lt;br /&gt;       NpgsqlCopyOut cout = new NpgsqlCopyOut( command, conn, Console.OpenStandardOutput() );&lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;           cout.Start();&lt;br /&gt;       }&lt;br /&gt;       catch(Exception e)&lt;br /&gt;       {&lt;br /&gt;           try&lt;br /&gt;           {&lt;br /&gt;               cout.End(); // return connection to Ready for Query state&lt;br /&gt;           }&lt;br /&gt;           catch(Exception e2)&lt;br /&gt;           {&lt;br /&gt;               throw new Exception(&quot;Failed to revive from copy: &quot; + e2 + &quot; upon failure: &quot; + e);&lt;br /&gt;           }&lt;br /&gt;           throw e;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;You can read COPY OUT data normally from a stream:&lt;/p&gt;  &lt;ol&gt; &lt;li&gt;Create NpgsqCopyOut object without specifying a stream    &lt;/li&gt;&lt;li&gt;Call Start() to initiate copy operation    &lt;/li&gt;&lt;li&gt;Read data in server-side encoding from NpgsqlCopyOut.CopyStream or row by    row from NpgsqlCopyOut.Read    &lt;/li&gt;&lt;li&gt;&lt;b&gt;During the operation the connection may not be used for anything    else.&lt;/b&gt;    &lt;/li&gt;&lt;li&gt;All data has been received when no more comes out (CopyStream.Read(...)    returns zero; NpgsqlCopyOut.Read a null pointer)    &lt;/li&gt;&lt;li&gt;The operation completes automatically upon end    &lt;/li&gt;&lt;li&gt;An ongoing operation may be cancelled by calling CopyStream.Close() or    NpgsqlCopyIn.End()    &lt;/li&gt;&lt;li&gt;Upon failure cancel the ongoing operation. Otherwise your &lt;b&gt;connection    may stay in copy mode, unusable for anything else&lt;/b&gt;. &lt;/li&gt; &lt;/ol&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public class CopyOutExample&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;       conn = new NpgsqlConnection(&quot;Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;&quot;);&lt;br /&gt;       conn.Open();&lt;br /&gt;&lt;br /&gt;       NpgsqlCommand command = new NpgsqlCommand(&quot;COPY myCopyTestTable TO STDOUT&quot;, conn);&lt;br /&gt;       NpgsqlCopyOut cout = new NpgsqlCopyOut( command, conn );&lt;br /&gt;&lt;br /&gt;       Stream outStream = Console.OpenStandardOutput();&lt;br /&gt;       Encoding serverEncoding = System.Text.Encoding.BigEndianUnicode; // example assumption&lt;br /&gt;       Encoding outEncoding = System.Text.Encoding.ASCII;&lt;br /&gt;&lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;           cout.Start();&lt;br /&gt;           Stream copyOutStream = cout.CopyStream;&lt;br /&gt;           byte[] buf = cout.Read; // complete first row&lt;br /&gt;           Console.Out.Write(buf,0,buf.Length);&lt;br /&gt;           int i;&lt;br /&gt;           while( (i = copyOutStream.Read(buf,0,buf.Length)) &gt; 0 )&lt;br /&gt;           {&lt;br /&gt;               buf = System.Text.Convert( serverEncoding, outEncoding, buf, 0, i );&lt;br /&gt;               Console.Out.Write( buf, 0, i );&lt;br /&gt;           }&lt;br /&gt;           copyOutStream.Close(); // or cout.End(), if you wish&lt;br /&gt;       }&lt;br /&gt;       catch(Exception e)&lt;br /&gt;       {&lt;br /&gt;           try&lt;br /&gt;           {&lt;br /&gt;               cout.End(); // return connection to Ready for Query state&lt;br /&gt;           }&lt;br /&gt;           catch(Exception e2)&lt;br /&gt;           {&lt;br /&gt;               throw new Exception(&quot;Failed to revive from copy: &quot; + e2 + &quot; upon failure: &quot; + e);&lt;br /&gt;           }&lt;br /&gt;           throw e;&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;System.Transactions Support&lt;/h3&gt;  &lt;p&gt;Thanks Josh Cooley, Npgsql has added initial support for System.Transactions.  This code is still in very early stage, so if you have any problems with it,  please let us know so we can fix it as soon as possible. &lt;/p&gt;  &lt;p&gt;In order to use it, you have to put the following in your connection  string:&lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt; Enlist=true&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;False is currently the default, but we will likely make enlist=true the  default once System.Transactions support stabilizes. &lt;/p&gt;  &lt;p&gt;Here is a sample code which uses System.Transactions support: &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System;&lt;br /&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;using System.Transactions;&lt;br /&gt;&lt;br /&gt;public class TransactionExample&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;   public static void Main(String[] args)&lt;br /&gt;   {&lt;br /&gt;&lt;br /&gt;           string connectionString = &quot;Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;Enlist=true&quot;;&lt;br /&gt;           using (TransactionScope tx = new TransactionScope())&lt;br /&gt;           {&lt;br /&gt;               using (NpgsqlConnection connection = new&lt;br /&gt;NpgsqlConnection(connectionString))&lt;br /&gt;               {&lt;br /&gt;                   connection.Open();&lt;br /&gt;                   using (NpgsqlCommand command = new&lt;br /&gt;NpgsqlCommand(&quot;insert into tablea (cola) values (&#39;b&#39;)&quot;, connection))&lt;br /&gt;                   {&lt;br /&gt;                       command.ExecuteNonQuery();&lt;br /&gt;                   }&lt;br /&gt;                   using (NpgsqlConnection connection2 = new&lt;br /&gt;NpgsqlConnection(connectionString))&lt;br /&gt;                   {&lt;br /&gt;                       connection2.Open();&lt;br /&gt;                       using (NpgsqlCommand command = new&lt;br /&gt;NpgsqlCommand(&quot;insert into tablea (colb) values (&#39;c&#39;)&quot;, connection2))&lt;br /&gt;                       {&lt;br /&gt;                           command.ExecuteNonQuery();&lt;br /&gt;                       }&lt;br /&gt;                   }&lt;br /&gt;               }&lt;br /&gt;               tx.Complete();&lt;br /&gt;           }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;h3&gt;3.1 Using Npgsql Logging support &lt;/h3&gt;  &lt;p&gt;Sometimes it&#39;s necessary to trace Npgsql&#39;s behaviour to track errors. Npgsql  can log messages to a specified file, to the console, or to both.  &lt;/p&gt; &lt;p&gt;There are three levels of logging:&lt;br /&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;None    &lt;/li&gt;&lt;li&gt;Normal    &lt;/li&gt;&lt;li&gt;Debug &lt;/li&gt; &lt;/ul&gt;   &lt;p&gt;The following NpgsqlEventLog static properties may also be specified:  &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Level - Can be one of the LogLevel enum values: None, Normal, Debug.    &lt;/li&gt;&lt;li&gt;LogName - Full path of the file where to log into.    &lt;/li&gt;&lt;li&gt;EchoMessages - Log to the console. &lt;/li&gt; &lt;/ul&gt;   &lt;p&gt;The example below shows you how to log data to the console and to a file  using level &quot;Debug&quot;: &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;using System.Data;&lt;br /&gt;using Npgsql;&lt;br /&gt;&lt;br /&gt;public static class NpgsqlUserManual&lt;br /&gt;{&lt;br /&gt; public static void Main(String[] args)&lt;br /&gt; {&lt;br /&gt;   // Enable logging.&lt;br /&gt;   NpgsqlEventLog.Level = LogLevel.Debug;&lt;br /&gt;   NpgsqlEventLog.LogName = &quot;NpgsqlTests.LogFile&quot;;&lt;br /&gt;   NpgsqlEventLog.EchoMessages = true;&lt;br /&gt;  &lt;br /&gt;   NpgsqlConnection conn = new NpgsqlConnection(&quot;Server=127.0.0.1;Port=5432;User Id=joe;Password=secret;Database=joedata;&quot;);&lt;br /&gt;   conn.Open();&lt;br /&gt;   conn.Close();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;Running this code gives the following output: &lt;/p&gt; &lt;pre class=&quot;CodeBox&quot;&gt;Set NpgsqlEventLog.EchoMessages = True&lt;br /&gt;Entering NpgsqlConnection.NpgsqlConnection()&lt;br /&gt;Entering NpgsqlConnection.ParseConnectionString()&lt;br /&gt;Connection string option: DATABASE = joedata&lt;br /&gt;Connection string option: SERVER = 127.0.0.1&lt;br /&gt;Connection string option: USER ID = joe&lt;br /&gt;Connection string option: PASSWORD = secret&lt;br /&gt;Entering NpgsqlConnection.Open()&lt;br /&gt;Connected to: 127.0.0.1:5432&lt;br /&gt;Entering NpgsqlConnection.WritestartupPacket()&lt;br /&gt;Entering NpgsqlStartupPacket.NpgsqlStartupPacket()&lt;br /&gt;Entering NpgsqlStartupPacket.WriteToStream()&lt;br /&gt;Entering PGUtil.WriteLimString()&lt;br /&gt;Entering PGUtil.WriteLimString()&lt;br /&gt;Entering PGUtil.WriteLimString()&lt;br /&gt;Entering PGUtil.WriteLimString()&lt;br /&gt;Entering PGUtil.WriteLimString()&lt;br /&gt;Entering NpgsqlConnection.HandleStartupPacketResponse()&lt;br /&gt;AuthenticationRequest message from Server&lt;br /&gt;Server requested cleartext password authentication.&lt;br /&gt;Entering NpgsqlPasswordPacket.NpgsqlPasswordPacket()&lt;br /&gt;Entering NpgsqlPasswordPacket.WriteToStream()&lt;br /&gt;Entering PGUtil.WriteString()&lt;br /&gt;Listening for next message&lt;br /&gt;AuthenticationRequest message from Server&lt;br /&gt;Listening for next message&lt;br /&gt;BackendKeyData message from Server&lt;br /&gt;Entering NpgsqlBackEndKeyData.ReadFromStream()&lt;br /&gt;Got ProcessID. Value: 3116&lt;br /&gt;Got SecretKey. Value: -132883070&lt;br /&gt;Listening for next message&lt;br /&gt;ReadyForQuery message from Server&lt;br /&gt;Listening for next message&lt;br /&gt;Connection completed&lt;br /&gt;Entering NpgsqlConnection.Close()&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;I used the &quot;Debug&quot; level to show that a lot of information can be obtained.  Of course, the &quot;Normal&quot; level is less verbose. (This data was written to file  NpgsqlTests.LogFile.)&lt;/p&gt;  &lt;h3&gt;3.2 Npgsql design time support - VS.Net support &lt;/h3&gt;  &lt;p&gt;Npgsql 0.6 and higher provide initial design time support. This means that  you can drag and drop a NpgsqlConnection in the Forms Designer of Visual Studio  .NET (just like with SqlConnections or OleDbConnections).&lt;br /&gt;In addition, a  dialog is available for easily editing and validating the ConnectionString. &lt;/p&gt;  &lt;p&gt;To do so you must:  &lt;/p&gt; &lt;ol&gt; &lt;li&gt;Install Npgsql.dll into the GAC    &lt;/li&gt;&lt;li&gt;Add a new Registry-Key below    &#39;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders&#39; and set    its default value to the path of your Npgsql.dll    &lt;/li&gt;&lt;li&gt;Open Visual Studio .NET    &lt;/li&gt;&lt;li&gt;Right-click the &quot;Data&quot; tab in the toolbox    &lt;/li&gt;&lt;li&gt;Click &quot;Add/Remove Element&quot;    &lt;/li&gt;&lt;li&gt;On the .Net tab, select NpgsqlConnection &lt;/li&gt; &lt;/ol&gt; For VS.Net 2005 you have  to &quot;Add a registry key under  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx  with whatever name you like ( I named mine PostgreSQL ) with a default value of  the directory ( trailing backslash ) where the assembly resides. &quot; Thanks Edward  Diener for tip.   &lt;p&gt;As result you will have an icon named NpgsqlConnection in the &quot;Data&quot; tab of  the toolbox. &lt;/p&gt;  &lt;h3&gt;3.3 ConnectionPool considerations &lt;/h3&gt;  &lt;p&gt;Npgsql will clear all connections from the pool whenever it finds any  problems with a connection. This will allow easy recovery from any instability  problems which might occur. Although this strategy may not have the best  performance implications, it will ensure that the pool remains stay consistent  when problems arise. Two methods to clear the pools are available through  NpgsqlConnection: ClearPool and ClearAllPools. You can use them to clear the  pool manually.  &lt;/p&gt; &lt;h2&gt;4. Current Npgsql Status &lt;/h2&gt;  &lt;h3&gt;Supported data types &lt;/h3&gt;  &lt;p&gt;Npgsql supports the following data types: &lt;/p&gt;  &lt;div align=&quot;center&quot;&gt; &lt;table border=&quot;1&quot;&gt;   &lt;tbody&gt;   &lt;tr class=&quot;H1&quot;&gt;     &lt;td&gt;Postgresql Type&lt;/td&gt;     &lt;td&gt;NpgsqlDbType&lt;/td&gt;     &lt;td&gt;System.DbType Enum&lt;/td&gt;     &lt;td&gt;.Net System Type&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;int8&lt;/td&gt;     &lt;td&gt;Bigint&lt;/td&gt;     &lt;td&gt;Int64&lt;/td&gt;     &lt;td&gt;Int64&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;bool&lt;/td&gt;     &lt;td&gt;Boolean&lt;/td&gt;     &lt;td&gt;Boolean&lt;/td&gt;     &lt;td&gt;Boolean&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;Box, Circle, Line, LSeg, Path, Point, Polygon&lt;/td&gt;     &lt;td&gt;Box, Circle, Line, LSeg, Path, Point, Polygon&lt;/td&gt;     &lt;td&gt;Object&lt;/td&gt;     &lt;td&gt;Object&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;bytea&lt;/td&gt;     &lt;td&gt;Bytea&lt;/td&gt;     &lt;td&gt;Binary&lt;/td&gt;     &lt;td&gt;Byte[]&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;date&lt;/td&gt;     &lt;td&gt;Date&lt;/td&gt;     &lt;td&gt;Date&lt;/td&gt;     &lt;td&gt;DateTime&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;float8&lt;/td&gt;     &lt;td&gt;Double&lt;/td&gt;     &lt;td&gt;Double&lt;/td&gt;     &lt;td&gt;Double&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;int4&lt;/td&gt;     &lt;td&gt;Integer&lt;/td&gt;     &lt;td&gt;Int32&lt;/td&gt;     &lt;td&gt;Int32&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;money&lt;/td&gt;     &lt;td&gt;Money&lt;/td&gt;     &lt;td&gt;Decimal&lt;/td&gt;     &lt;td&gt;Decimal&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;numeric&lt;/td&gt;     &lt;td&gt;Numeric&lt;/td&gt;     &lt;td&gt;Decimal&lt;/td&gt;     &lt;td&gt;Decimal&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;float4&lt;/td&gt;     &lt;td&gt;Real&lt;/td&gt;     &lt;td&gt;Single&lt;/td&gt;     &lt;td&gt;Single&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;int2&lt;/td&gt;     &lt;td&gt;Smallint&lt;/td&gt;     &lt;td&gt;Int16&lt;/td&gt;     &lt;td&gt;Int16&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;text&lt;/td&gt;     &lt;td&gt;Text&lt;/td&gt;     &lt;td&gt;String&lt;/td&gt;     &lt;td&gt;String&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;time, timetz&lt;/td&gt;     &lt;td&gt;Time&lt;/td&gt;     &lt;td&gt;Time&lt;/td&gt;     &lt;td&gt;DateTime&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;timestamp&lt;/td&gt;     &lt;td&gt;Timestamp&lt;/td&gt;     &lt;td&gt;DateTime&lt;/td&gt;     &lt;td&gt;DateTime&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;timestamptz&lt;/td&gt;     &lt;td&gt;TimestampTZ&lt;/td&gt;     &lt;td&gt;DateTime&lt;/td&gt;     &lt;td&gt;DateTime&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;varchar&lt;/td&gt;     &lt;td&gt;Varchar&lt;/td&gt;     &lt;td&gt;String&lt;/td&gt;     &lt;td&gt;String&lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;inet&lt;/td&gt;     &lt;td&gt;Inet&lt;/td&gt;     &lt;td&gt;Object&lt;/td&gt;     &lt;td&gt;NpgsqlInet, IPAddress&lt;br /&gt;(there is an implicity cast operator to        convert NpgsqlInet objects into IPAddress if you need to use IPAddress and        have only NpgsqlInet) &lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;bit&lt;/td&gt;     &lt;td&gt;Bit&lt;/td&gt;     &lt;td&gt;Boolean&lt;/td&gt;     &lt;td&gt;Boolean, Int32&lt;br /&gt;(If you use an Int32 value, odd values will be        translated to bit 1 and even values to bit 0) &lt;/td&gt;&lt;/tr&gt;   &lt;tr class=&quot;H2&quot;&gt;     &lt;td&gt;uuid&lt;/td&gt;     &lt;td&gt;Uuid&lt;/td&gt;     &lt;td&gt;Guid&lt;/td&gt;     &lt;td&gt;Guid&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;  &lt;h3&gt;Features &lt;/h3&gt;  &lt;ul&gt; &lt;li&gt;You can send select, insert, delete queries    &lt;/li&gt;&lt;li&gt;You can call functions    &lt;/li&gt;&lt;li&gt;You can get resultset from functions    &lt;/li&gt;&lt;li&gt;You can use parameters in your queries. Input, Output and InputOuput    parameters are supported    &lt;/li&gt;&lt;li&gt;Parameter names have &quot;:&quot; markers or &quot;@&quot; markers to easy migration of code.    :parameter -or- @parameter    &lt;/li&gt;&lt;li&gt;Support for transactions &lt;/li&gt; &lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/3871967391136726030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/3871967391136726030' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/3871967391136726030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/3871967391136726030'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/01/npgsql-is-net-data-provider-for.html' title='Npgsql is a .Net Data Provider for the PostgreSQL Database Server'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-362713652085950636</id><published>2008-01-30T10:54:00.000+05:30</published><updated>2008-01-30T10:57:38.860+05:30</updated><title type='text'>Add the tab between strings</title><content type='html'>If u want to add the tab between the strings use &lt;span style=&quot;font-weight: bold;&quot;&gt;Controlchars.tab()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For example :&lt;br /&gt;Dim str as string&lt;br /&gt;str = &quot;siva&quot; + controlchars.tab() + &quot;kumar&quot;&lt;br /&gt;console.writeline(str)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;o/p : siva    kumar</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/362713652085950636/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/362713652085950636' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/362713652085950636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/362713652085950636'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/01/add-tab-between-strings.html' title='Add the tab between strings'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-192232339662325434</id><published>2008-01-18T10:29:00.000+05:30</published><updated>2008-01-18T11:21:04.813+05:30</updated><title type='text'>Linux - Memory Leakage</title><content type='html'>In Linux the &lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_0&quot;&gt;valgrind&lt;/span&gt;&lt;/span&gt; tool &lt;/span&gt;help us to detect the memory leakage in our coding.&lt;br /&gt;&lt;br /&gt;For Example&lt;br /&gt; if your application &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;exec&lt;/span&gt; is named as &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_2&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_1&quot;&gt;myexec&lt;/span&gt;&lt;/span&gt;, then run the command as below&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_3&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_2&quot;&gt;valgrind&lt;/span&gt;&lt;/span&gt; --tool=&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_4&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_3&quot;&gt;memcheck&lt;/span&gt;&lt;/span&gt; --leak-check=yes --&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_5&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_4&quot;&gt;num&lt;/span&gt;&lt;/span&gt;-callers=25 ./&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_6&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_5&quot;&gt;myexec&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Note :- when your running the exec with &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_6&quot;&gt;valgrind&lt;/span&gt; tool run the exec with &lt;span style=&quot;font-weight: bold;&quot;&gt;./ &lt;/span&gt;(dot slash)&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;    when your application needs to pass &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_7&quot;&gt;arguments&lt;/span&gt; with the exec run tool with &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_8&quot;&gt;argument&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_9&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_7&quot;&gt;valgrind&lt;/span&gt;&lt;/span&gt; --tool=&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_10&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_8&quot;&gt;memcheck&lt;/span&gt;&lt;/span&gt; --leak-check=yes --&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_11&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_9&quot;&gt;num&lt;/span&gt;&lt;/span&gt;-callers=25 ./&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_12&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_10&quot;&gt;myexec&lt;/span&gt;&lt;/span&gt; -&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_13&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_11&quot;&gt;ORBInitRef&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_14&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_12&quot;&gt;NameServic&lt;/span&gt;&lt;/span&gt;=&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_15&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_13&quot;&gt;corbaloc&lt;/span&gt;&lt;/span&gt;:&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_16&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_14&quot;&gt;iiop&lt;/span&gt;&lt;/span&gt;:&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_17&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_15&quot;&gt;localhost&lt;/span&gt;&lt;/span&gt;/&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_18&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_16&quot;&gt;NameService&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_19&quot;&gt;&lt;span class=&quot;blsp-spelling-error&quot; id=&quot;SPELLING_ERROR_17&quot;&gt;Memcheck&lt;/span&gt;&lt;/span&gt; performs a range of memory-checking functions,including detecting accesses to uninitialized memory, misuse of allocated memory (double frees, access after free, etc.) and detecting memory leaks.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; font-style: italic;&quot;&gt;Note : use the latest tool version to get the best &lt;span class=&quot;blsp-spelling-corrected&quot; id=&quot;SPELLING_ERROR_20&quot;&gt;performance&lt;/span&gt;. &lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/192232339662325434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/192232339662325434' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/192232339662325434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/192232339662325434'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/01/linux-memory-error-detector.html' title='Linux - Memory Leakage'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-2594159406997688786</id><published>2008-01-18T08:47:00.001+05:30</published><updated>2008-01-18T08:47:38.552+05:30</updated><title type='text'>Internet Sharing Using Squid</title><content type='html'>Internet Sharing in linux (Squid)&lt;br /&gt;&lt;br /&gt;Squid’s main configuration file is in /etc/squid/squid.conf.&lt;br /&gt;Edit the file&lt;br /&gt;Open /etc/squid/squid.conf&lt;br /&gt;You will need to either find and uncomment entries, or modify existing uncommented lines in the squid configuration file. Use text editor or a text find to locate these lines: visible_hostname machine-name or IPhttp_port 3128cache_dir ufs /var/spool/squid 1000 16 256cache_access_log /var/log/squid/access.log&lt;br /&gt;In the acl section near the bottom add:acl intranet 192.168.10.0/24  à Allow all the machines to access.http_access allow lcsintranet.com (lcsintranet.com – hostname) &lt;br /&gt;visible_hostname - Create this entry and set this to the hostname of the machine. To find the hostname, use the command hostname. Not entering a value may cause squid to fail as it may not be able to automatically determine the fully qualified hostname of your machine.&lt;br /&gt;http_port 3128 - Uncomment this line but there is no need to edit it unless you want to change the default port for http connections.&lt;br /&gt;cache_dir ufs /var/spool/squid 1000 15 256 - Uncomment this line. You may want to append a zero to the value 100 which will make the cache size 1000MB instead of 100MB. The last two values stand for the default folder depth the cache will create on the top and subdirectories respectively. They do not need modification.&lt;br /&gt;cache_access_log - Uncomment this line. This is where all requests to the proxy server will get logged.&lt;br /&gt;acl intranet 192.168.10.0/24 - This entry needs to be added. It should correspond to whatever your local network range is.&lt;br /&gt;http_access allow intranet - This allows the acl named intranet to use the proxy server. Make sure to put allow directives above the last ‘http_access deny all’ entry, as it will overide any allow directives below it.&lt;br /&gt;&lt;br /&gt;To allow a single address to access a specific URL&lt;br /&gt;This example allows only the special_client to access the special_url. Any other client that tries to access the special_url is denied. acl special_client src 192.168.10.3acl special_url url_regex ^http://www.squid-cache.org/Doc/FAQ/$http_access allow special_client special_urlhttp_access deny special_url   To allow a particular address to access a list of URL acl special_client src 192.168.10.3acl special_client src “/etc/squid/ip.txt” à (Make a file ip.txt and add the                                                                                               to access the particular URL)acl lcssite url_regex –i “/etc/squid/site.txt”  à (Make a file site.txt add                                                   the URL)&lt;br /&gt;&lt;br /&gt;Turning on squid&lt;br /&gt;Start the service:service squid start&lt;br /&gt;Verify that squid is running :service squid status&lt;br /&gt;&lt;br /&gt;Configuring the clients&lt;br /&gt;If you are using Firefox or Mozilla you will need to add the proxy server as follows:&lt;br /&gt;Go to Preferences&gt;Network&gt;Settings&lt;br /&gt;Add the name of your new proxy server and port 3128 to the http proxy field</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/2594159406997688786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/2594159406997688786' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/2594159406997688786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/2594159406997688786'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/01/internet-sharing-using-squid.html' title='Internet Sharing Using Squid'/><author><name>Sathees</name><uri>http://www.blogger.com/profile/02011018968515594961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-6841585177879933172</id><published>2008-01-18T08:45:00.000+05:30</published><updated>2008-01-18T08:46:14.495+05:30</updated><title type='text'>Linux Volume Control Settings</title><content type='html'>Th &lt;strong&gt;amixer&lt;/strong&gt; command is used to adjsut the volume of sound card.</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/6841585177879933172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/6841585177879933172' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6841585177879933172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6841585177879933172'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/01/linux-volume-control-settings.html' title='Linux Volume Control Settings'/><author><name>Sathees</name><uri>http://www.blogger.com/profile/02011018968515594961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-4357720668546839772</id><published>2008-01-18T08:43:00.000+05:30</published><updated>2008-01-18T08:44:20.141+05:30</updated><title type='text'>Linux Disk Copy</title><content type='html'>HardDisk Copy In Linux&lt;br /&gt;(Disk to Disk Copy)&lt;br /&gt;&lt;br /&gt;Connect two hard disk in the mother board.&lt;br /&gt;Boot the system with the data hard disk.&lt;br /&gt;Run the following command to know the hard disk name,&lt;br /&gt;#  fdisk -l   (shows booted H/D)&lt;br /&gt;#  ls /dev/   (shows the other H/D)&lt;br /&gt;Let the data containing hardisk be HDA and the data in which to be copied be HDB.&lt;br /&gt;Now execute the below command to copy the hard disk.&lt;br /&gt;&lt;br /&gt;#  dd if=/dev/hda of=/dev/hdb bs=1024k&lt;br /&gt;&lt;br /&gt;Now the data&#39;s with start to copy.</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/4357720668546839772/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/4357720668546839772' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/4357720668546839772'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/4357720668546839772'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/01/linux-disk-copy.html' title='Linux Disk Copy'/><author><name>Sathees</name><uri>http://www.blogger.com/profile/02011018968515594961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-6253987787670356271</id><published>2008-01-18T08:41:00.000+05:30</published><updated>2008-01-18T08:42:48.685+05:30</updated><title type='text'>Postgres Installation error in Xp Embedded</title><content type='html'>&lt;u&gt;Postgres installation error in xp embedded&lt;br /&gt;&lt;/u&gt;&lt;br /&gt; &lt;strong&gt;Failed to run initdb:1&lt;br /&gt;&lt;/strong&gt; Solution : Add null device driver while creating a xpembedded image.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Secondary service logon failure&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;Solution : Add runas service  while creating a xpembedded image.</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/6253987787670356271/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/6253987787670356271' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6253987787670356271'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/6253987787670356271'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/01/postgres-installation-error-in-xp.html' title='Postgres Installation error in Xp Embedded'/><author><name>Sathees</name><uri>http://www.blogger.com/profile/02011018968515594961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3593194529034575387.post-577472713101468020</id><published>2008-01-18T08:20:00.000+05:30</published><updated>2008-01-18T08:27:35.986+05:30</updated><title type='text'>Linux Process Memory Usage</title><content type='html'>The following shell script is used to monitor the memory usage of a process.&lt;br /&gt;Save the following script in a file (for ex, memusage.sh)  and run it with the process name you want to monitor.&lt;br /&gt;&lt;br /&gt;for ex, ./memusage.sh myapp&lt;br /&gt;Now the script log the mem usage in memusage.csv file for every 2 secs. You can change the time period by change the PERIOD value in the script.&lt;br /&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;#GetmemUsageModified2&lt;br /&gt;USAGE=&quot;Usage: $0 processName&quot;&lt;br /&gt;if [ $# -ne 1 ]; then&lt;br /&gt;echo $USAGE&lt;br /&gt;exit 1&lt;br /&gt;fi&lt;br /&gt;# In case the monitored process has not yet started&lt;br /&gt;# keep searching until its PID is found&lt;br /&gt;PROCESS_PID=&quot;&quot;&lt;br /&gt;while :&lt;br /&gt;do&lt;br /&gt;PROCESS_PID=`/sbin/pidof $1`&lt;br /&gt;if [ &quot;$PROCESS_PID.X&quot; != &quot;.X&quot; ]; then&lt;br /&gt;break&lt;br /&gt;fi&lt;br /&gt;done&lt;br /&gt;LOG_FILE=&quot;memusage.csv&quot;&lt;br /&gt;echo &quot;ElapsedTime,VmSize,VmRSS&quot; &gt; $LOG_FILE&lt;br /&gt;ELAPSED_TIME=`date`&lt;br /&gt;PERIOD=2 # seconds&lt;br /&gt;while :&lt;br /&gt;do&lt;br /&gt;if [ -d /proc/$PROCESS_PID ] ; then&lt;br /&gt;VM_SIZE=`awk &#39;/VmSize/ {print $2}&#39; &lt; /proc/$PROCESS_PID/status`&lt;br /&gt;if [ &quot;$VM_SIZE.X&quot; = &quot;.X&quot; ]; then&lt;br /&gt;continue&lt;br /&gt;fi&lt;br /&gt;VM_RSS=`awk &#39;/VmRSS/ {print $2}&#39; &lt; /proc/$PROCESS_PID/status`&lt;br /&gt;if [ &quot;$VM_RSS.X&quot; = &quot;.X&quot; ]; then&lt;br /&gt;continue&lt;br /&gt;fi&lt;br /&gt;echo &quot;$ELAPSED_TIME,$VM_SIZE,$VM_RSS&quot; &gt;&gt; $LOG_FILE&lt;br /&gt;sleep $PERIOD&lt;br /&gt;VM_SIZE=&quot;&quot;&lt;br /&gt;VM_RSS=&quot;&quot;&lt;br /&gt;ELAPSED_TIME=`date +%H:%M:%S:%N`&lt;br /&gt;else&lt;br /&gt;echo &quot;$1 is no longer a running process&quot;&lt;br /&gt;exit 0&lt;br /&gt;fi&lt;br /&gt;done</content><link rel='replies' type='application/atom+xml' href='http://opentips.blogspot.com/feeds/577472713101468020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3593194529034575387/577472713101468020' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/577472713101468020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3593194529034575387/posts/default/577472713101468020'/><link rel='alternate' type='text/html' href='http://opentips.blogspot.com/2008/01/linux-process-memory-usage.html' title='Linux Process Memory Usage'/><author><name>Sathees</name><uri>http://www.blogger.com/profile/02011018968515594961</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>