How To Run A Postgres Stored Proc Or Function In C#

IT Support Forum Forums Development C# Development C# Coding How To Run A Postgres Stored Proc Or Function In C#

This topic contains 0 replies, has 1 voice, and was last updated by  Webmaster 1 week, 4 days ago.

  • Author
    Posts
  • #2383

    Webmaster
    Keymaster

    Here’s how to run a Postgres Function or Postgres Stored Procedure using C#

    NpgsqlCommand SqlCommand = new NpgsqlCommand(“stored_proc_name”)
    { CommandType = CommandType.StoredProcedure };

    SqlCommand.Parameters.AddWithValue(“param_name1”, NpgsqlTypes.NpgsqlDbType.Text, “param 1”);
    SqlCommand.Parameters.AddWithValue(“param_name2”, NpgsqlTypes.NpgsqlDbType.Text, “param 2”);

    You can then execute the NpgsqlCommand in the normal way.

You must be logged in to reply to this topic.