From: | Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> |
---|---|
To: | Jonas Wouters <Jonas(at)vanroey(dot)be> |
Cc: | "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org>, "'pgsql-cygwin(at)postgresql(dot)org'" <pgsql-cygwin(at)postgresql(dot)org> |
Subject: | Re: [SQL] Returning a recordset and filling datatable in a .NET |
Date: | 2002-10-31 16:07:35 |
Message-ID: | Pine.LNX.4.44.0210311805000.3526-100000@matrix.gatewaynet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-cygwin pgsql-sql |
On Thu, 31 Oct 2002, Jonas Wouters wrote:
Hi altho i doubt anybody here has any .net experience,
i'll give my bet.
try to place your sql commands in such a way the the
"FETCH ALL" command is the last in the stream,
(that is get rid of begin,commit statements)
>
>
> Hi,
>
> I have a problem with using .NET and PostgreSQL. In a previous thread called
> "" I noticed that it is possible to use and create functions that return
> tuples or RecordSets. I now want to use them in .NET.
>
> I followed the instructions which are available at :
> http://developer.postgresql.org/docs/postgres/plpgsql-cursors.html these
> work in the standard psql client :
>
> I created the function using the following :
>
> CREATE FUNCTION public.p0012_fetch_supplier(varchar, varchar, refcursor)
> RETURNS refcursor AS '
> BEGIN
> OPEN $3 FOR SELECT * FROM "SUPP_T" WHERE "CODE" = $1 AND "DSRCODE" =
> $2;
> RETURN $3;
> END;
> ' LANGUAGE 'plpgsql' VOLATILE;
>
>
> Then I did these in psql :
>
> SBA=# BEGIN;
> BEGIN
> SBA=# SELECT p0012_fetch_supplier('1','1','funccursor');
> p0012_fetch_supplier
> ----------------------
> funccursor
> (1 row)
>
> SBA=# FETCH ALL IN funccursor;
> DSRCODE | CODE
> 1 | 1
> (1 row)
>
> SBA=# COMMIT;
> COMMIT
>
> The results tell me that the function works. (whoohoo)
>
> But when I do the same thing in a .Net application, I get an empty DataTable
> (row count = 0)
>
> This is what I do in .Net 5and I do know that most of you people dislike
> .NET and actually .. that is not the issue for me :), I just want this to
> work because we are going to need this for our application)
>
>
> Dim CN As New Microsoft.Data.Odbc.OdbcConnection("DSN=PostgreSQL30")
> Dim CM As New Microsoft.Data.Odbc.OdbcCommand("BEGIN; SELECT
> p0012_fetch_supplier('1','1','funccursor'); FETCH ALL IN
> funccursor; COMMIT;", CN)
> Dim DA As New Microsoft.Data.Odbc.OdbcDataAdapter(CM)
> Dim DT As New DataTable()
> Try
>
> CM.CommandType = CommandType.Text
> DA.SelectCommand.Connection.Open()
> DA.Fill(DT)
> DA.SelectCommand.Connection.Close()
> Catch ex As Microsoft.Data.Odbc.OdbcException
> Debug.WriteLine(ex.Message)
> Debug.WriteLine(ex.Source)
> Debug.WriteLine(ex.HelpLink)
> Finally
> CN.Close()
>
> It does not raise an exception so there are no real 'errors'; it just does
> not give 'data' to the ADO.NET container.
>
> If I am asking this in the wrong mailinglist, then please point me in the
> right direction. I don't think that I will get a answer at Microsoft.com so
> that is why I ask it here ..
>
>
> Thx in advance
> Jonas
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
==================================================================
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
Nikis 4, Glyfada
Athens 16610
Greece
tel: +30-10-8981112
fax: +30-10-8981877
email: achill(at)matrix(dot)gatewaynet(dot)com
mantzios(at)softlab(dot)ece(dot)ntua(dot)gr
From | Date | Subject | |
---|---|---|---|
Next Message | Brian Murphy | 2002-10-31 17:06:57 | Cygwin: ip-daemon install service problem |
Previous Message | Jason Tishler | 2002-10-31 16:06:30 | Re: Problem configuring Postgres under Cygwin |
From | Date | Subject | |
---|---|---|---|
Next Message | Wei Weng | 2002-10-31 18:21:25 | How do you write this query? |
Previous Message | Jonas Wouters | 2002-10-31 15:33:08 | Returning a recordset and filling datatable in a .NET applicatio n |