Обсуждение: Insert into postgre database from a stored procedure

Поиск
Список
Период
Сортировка

Insert into postgre database from a stored procedure

От
techsupport@datatronicsnig.com
Дата:
  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");

            }
        }

Re: Insert into postgre database from a stored procedure

От
Lutz Horn
Дата:
> 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

How is the stored procedure "public.spabsecode_insert" defined? Does it
accept the two parameters "absecodex" and "absedescx"?

Please show us the code of the stored procedure.

Lutz