Discussion:
Insert into postgre database from a stored procedure
t***@datatronicsnig.com
2018-12-03 02:34:41 UTC
Permalink
 

Hi

I have C#  application that uses Dapper as its ORM

I am trying insert  records into a postgresql database through a stored procedure

I get a syntax error on  cmd.ExecuteNonQuery();  line

Can you please mail me some documents to help me solve the problem or point me 

in the direction of the documents i should be reading.

my script is shown below

Thanks

Olukay

 


  NpgsqlConnection conn = new NpgsqlConnection("Host = 127.0.0.1; Database = Tournaments; Port = 5432; Username = postgres; Password = manager");
            conn.Open();
                                 
            {
                NpgsqlCommand cmd = new NpgsqlCommand("public.spabsecode_insert", conn);
                var p = new DynamicParameters();

                cmd.Parameters.Add(new NpgsqlParameter("absecodex", model.Absecode));
                cmd.Parameters.Add(new NpgsqlParameter("absedescx", model.Absedesc));

                cmd.ExecuteNonQuery();

                model.Id = p.Get<int>("Id");

            }
        }

Loading...