1

ERROR: 42883: function insertvideo(character varying, character varying, double precision, integer) does not exist

But that Stored Procedure exist!!! Why continue this error???

This is my connection string:

 <connectionStrings>
        <add name="myConnection" connectionString="Server=127.0.0.1; 
                   User Id=postgres; Password=myPass; Database=myDB; "/>
      </connectionStrings>

Stored Procedure is in public schema and work correctly.

    using (NpgsqlConnection conn = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["AxWaveConnection"].ToString()))
    {
        try
        {
            conn.Open();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

        NpgsqlCommand cmd = new NpgsqlCommand("insertvideo", conn);
        cmd.CommandType = System.Data.CommandType.StoredProcedure;


        cmd.Parameters.Add(new NpgsqlParameter("out_scope_id", NpgsqlDbType.Bigint));
            cmd.Parameters["out_scope_id"].Direction = ParameterDirection.Output;

        cmd.Parameters.Add(new NpgsqlParameter("in_youtubeidvideo", NpgsqlDbType.Varchar, 15));
        cmd.Parameters["in_youtubeidvideo"].Value = VideoId;

        cmd.Parameters.Add(new NpgsqlParameter("in_title", NpgsqlDbType.Varchar, 200));
        cmd.Parameters["in_title"].Value = Title;

        cmd.Parameters.Add(new NpgsqlParameter("in_rating", NpgsqlDbType.Double));
        cmd.Parameters["in_rating"].Value = Rating;

        cmd.Parameters.Add(new NpgsqlParameter("in_viewcount", NpgsqlDbType.Integer));
        cmd.Parameters["in_viewcount"].Value = ViewCount;


        try
        {
            cmd.ExecuteNonQuery();

            scopeID = Convert.ToInt64(cmd.Parameters["out_scope_id"].Value);
        }
        catch (Exception e)
        {
            scopeID = -1;        //Duplicate Record
        }

        conn.Close();
2
  • do you mean Stored Procedure? Commented Jan 31, 2013 at 9:29
  • 1
    One thing to consider is that postgres includes the parameter types as part of the function name. So if you're passing parameters of a different type than the function definition, it will report it as not found even if the names are the same. Commented Feb 1, 2013 at 14:58

3 Answers 3

1

Server=127.0.0.1; add name="ConnectionStringName" connectionString="server=ServerNameOrIP;database=DataBasename;uid=UserID;pwd=Password; Check this Correctly an try again. It will work. Database connection not established.

1
  • 2
    the connection is working, otherwise he would give exception when opening.. dont it? Commented Jan 31, 2013 at 9:43
0

You cannot pass function in NpgsqlCommand command object. The only allowed there is sql query or the name of the stored procedure.

The best way to do is to create a STORED PROCEDURE with the function inside it and call the procedure in ado.net.

2
  • 1
    sorry but i'm a beginner in postgresql... i can create tables, views, functions, queries, reports, but not stored procedures... in all tutorials i'd never see: CREATE PROCEDURE Commented Jan 31, 2013 at 9:45
  • You CAN call a PostGreSQL function from ADO.Net. It is very similar to calling a stored procedure on SQL Server. PostGreSQL does not have stored procedures, only functions, which do for PostGreSQL the same basic things you would use stored procedures for in SQL Server. Commented Oct 30, 2017 at 21:51
0

Please add below connection string

<connectionStrings>
            <add name="myConnection" connectionString="Server=127.0.0.1; 
                       User Id=postgres; Password=myPass; Database=myDB; " providerName="postgre"/>
          </connectionStrings>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.