[Mono-list] Which postgres client library?

Francisco Figueiredo Jr. fxjrlists@yahoo.com.br
Sun, 11 May 2003 11:33:06 -0300 (ART)


Stuart Ballard wrote:

>Off the top of my head:

>string sql = "select * from table where name = :name";
>string testValue = "TestValue";
>NpgsqlConnection conn = new NpgsqlConnection(connStr);
>NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);
>NpgsqlParameter param = new NpgsqlParameter();
>param.ParameterName = "name";
>param.DbType = DbType.String;
>param.Size = testValue.Length;
>param.Value = testValue;
>cmd.Parameters.Add(param);
>NpgsqlDataReader dr = cmd.ExecuteReader();
>...



Yes, we were with this problems, but thanks Stuart Ballard which provided us
with his test cases, and later another one about inserting DBNull values
everything is working with the latests cvs code.
Mail thread can be found at: 
<http://gborg.postgresql.org/pipermail/npgsql-general/2003-May/000446.html>


>"You can reduce your lines-of-code count by passing the name, type and 
>size to the constructor of NpgsqlParameter but I forget what the exact 
>order of arguments is. Or you can do what I do, which is write a 
>function to create a parameter with a particular name, type, size and 
>value so it all happens in one line.

>The benefit of this is supposedly that it's type-safe and you don't need 
>to worry about quoting your parameter values, and the DB provider can 
>optimise it by only sending the query once and sending different sets of 
>parameters for the query. It looks like the Npgsql provider isn't 
>implementing it correctly, though.


On server versions 7.3+ you can use the Prepare method of the command object
exactly to do this. It uses the prepare support to create a plan of the query
and later just sends the values in the parameters.


>Does anyone know if there are any plans to update Mono's Npgsql to their 
>latest CVS?

I'm taking care of this right now. I'm justing clarifying a possible license
issue because Npgsql uses a port of MD5.cs from Postgresql code. This file was
contributed because the lack of its support in the .Net Compact Framework 
which could be a possible target of Npgsql and also because an transformation
of the return was needed also. Please check full story at:
<http://gborg.postgresql.org/pipermail/npgsql-hackers/2003-February/000005.html>
 
Again, thanks Stuart for helping us tracking this bugs.


=====
Regards,
Francisco Figueiredo Jr.
---
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi

_______________________________________________________________________
Yahoo! Mail
O melhor e-mail gratuito da internet: 6MB de espaço, antivírus, acesso POP3, filtro contra spam. 
http://br.mail.yahoo.com/