function error: cannot execute a null query string

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Guest

function error: cannot execute a null query string

Post by Guest » Mon 18 Apr 2005 12:45

I'm getting an error when running a function. Normal select queries work fine.

Code: Select all

string connString = "host=; user id=; database=;";
PgSqlConnection conn = new PgSqlConnection( connString );
PgSqlCommand command = new PgSqlCommand( "adaption.funcampaignstats", conn );
command.Parameters.Add( "adsf", PgSqlType.Int, 4, "1960" );
command.CommandType = CommandType.StoredProcedure;

PgSqlDataAdapter da = new PgSqlDataAdapter();
da.SelectCommand = command;

DataSet dataSet = new DataSet();
da.Fill( dataSet );

Response.Write( "0: " + dataSet.Tables[0].Rows[0][0] + "" );
Response.Write( "1: " + dataSet.Tables[0].Rows[0][1] + "" );
Response.Write( "2: " + dataSet.Tables[0].Rows[0][2] + "" );
This is the error it gives

Code: Select all

cannot EXECUTE a null querystring 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: CoreLab.PostgreSql.PgSqlException: cannot EXECUTE a null querystring

Source Error: 


Line 32: 
Line 33: 			DataSet dataSet = new DataSet();
Line 34: 			da.Fill( dataSet );
Line 35: 
Line 36: 			Response.Write( "0: " + dataSet.Tables[0].Rows[0][0] + "" );
 

Source File: c:\inetpub\wwwroot\regmanweb\mailing\pg_test.aspx.cs    Line: 34 

Stack Trace: 


[PgSqlException: cannot EXECUTE a null querystring]
   CoreLab.PostgreSql.PgSqlCommand.ExecuteReader(CommandBehavior behavior) +347
   CoreLab.PostgreSql.PgSqlCommand.c(CommandBehavior A_0) +19
   System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
   Regman.Web.Mailing.pg_test.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\regmanweb\mailing\pg_test.aspx.cs:34
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +750

Guest

Post by Guest » Mon 18 Apr 2005 18:52

I figured out that I just need to do

Code: Select all

command.Parameters.Add( , ,  ).Value = ;
Not sure why it doesn't work the other way.

Now I have a new problem. I'm returning type that is ( int, int, int ), and I get this error:

Code: Select all

ERROR: cannot display a value of type record 
It looks like it thinks it's a record instead of 3 ints.

Yuri
Posts: 140
Joined: Mon 08 Nov 2004 12:07

Post by Yuri » Tue 19 Apr 2005 14:10

Send us please small demo project to demonstrate the problem and include script to create server objects.

Post Reply