开发者

FillinValues failed with Postgres Update

开发者 https://www.devze.com 2023-02-28 15:10 出处:网络
I\'m trying to do an update with an WPF application through a Postgres Function but an exception is raised..

I'm trying to do an update with an WPF application through a Postgres Function but an exception is raised.. "FillinValues failed".. I don't really understand why.. Thnks for help.. Here is the C# Code:

public static int UpdateCategorie(int aID_CAT, string aINTITULE_CAT, string aDESCRIPTION_CAT, int? aPID_CAT)
    {
        using (OleDbConnection connex = new OleDbConnection(ConfigurationManager.ConnectionStrings["BMGDB"].ToString()))
        {
            OleDbCommand command = new OleDbCommand("UpdateCategorie", connex);                
            command.Parameters.Add("IDCategorie", OleDbType.VarChar).Value = aID_CAT;
            command.Parameters.Add("Intitule", OleDbType.VarChar).Value = aINTITULE_CAT;
            command.Parameters.Add("Description", OleDbType.VarChar).Value = aDESCRIPTION_CAT;
            //command.Parameters.Add("PID", OleDbType.Integer).Value = aPID_CAT;

            if (aPID_CAT == null)
            {
                command.Parameters.Add("PID", OleDbType.Integer).Value = null;
            }
            else
            {
                command.Parameters.Add("PID", OleDbType.Integer).Value = (int)aPID_CAT;
            }

            connex.Open();
            int rows = command.ExecuteNonQuery(); //permet de retourner un entier indiquant le nbr de row affectées
            connex.Close();
            if (rows == 1)
            {
                return 1; // TODO - ShowDialog
            }
            else
            {
                return -1;// TODO - ShowDialog
            }
        }
    }

Here's the Postgres function :

  CREATE OR REPLACE FUNCTION UpdateCategorie(IDcategorie INTEGER, Intitule TEXT, Description TEXT开发者_运维百科, PID INTEGER) RETURNS VOID
AS $$
  BEGIN
  INSERT INTO CATEGORIE_HIST (ID_CAT, Intitule_CAT, Description_CAT, Modification_CAT, PID_CAT)
    SELECT c.ID_CAT, c.Intitule_CAT, c.Description_CAT, c.Modification_CAT, PID_CAT
    FROM CATEGORIE c
    WHERE c.ID_CAT = $1
    ;
  UPDATE CATEGORIE
    SET Intitule_CAT = $2,
      Description_CAT = $3,
      PID_CAT = $4,
      Modification_CAT = CURRENT_TIMESTAMP
    WHERE ID_CAT = $1;
  END;
  $$
LANGUAGE plpgsql
;

Here's the stacktrace of Exception:

   à System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
   à System.Data.OleDb.OleDbCommand.ExecuteCommandTextForMultpleResults(tagDBPARAMS dbParams, Object& executeResult)
   à System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   à System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   à System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   à System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
   à BMG.DAL.Data_Provider.UpdateCategorie(Int32 aID_CAT, String aINTITULE_CAT, String aDESCRIPTION_CAT, Nullable`1 aPID_CAT) dans Projects\BMG\Code c#\BMG.BackOffice\BMG.DAL\Classes\Data_Provider.cs:ligne 399
   à BMG.BLL.Classes.CATEGORIE_MANAGER.Update(Int32 aID_CAT, String aINTITULE_CAT, String aDESCRIPTION_CAT, Nullable1 aPID_CAT) dansProjects\BMG\Code \BMG.BLL\Classes\CATEGORIE_MANAGER.cs:ligne 128

Error seems to be in the oledbprovider.. Thanks for help!


Some quick googling turned up a few links to the EnterpriseDB forums from 2006 as well as this thread about the PgOleDb driver from January 2, 2011. Is there a reason you're not using a managed ADO.NET provider? Npgsql is an ADO.NET provider that is under active development.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号