I run these commands in a Windows Forms app written in C#:
NpgsqlCommand command = new NpgsqlCommand("DO $$ BEGIN IF EXISTS(select id from clients where id=@cnumberclient) THEN INSERT INTO reservations(roomnumber,clientnumber,datein, dateout) values(@rnumber, @cnumber, @din, @dout); ELSE raise notice 'HYI'; END IF; END $$;", conn.getConnection());
command.Parameters.Add("@cnumber", NpgsqlDbType.Integer).Value = ClientId;
command.Parameters.Add("@cnumberclient", NpgsqlDbType.Integer).Value = ClientId;
command.Parameters.Add("@rnumber", NpgsqlDbType.Integer).Value = RoomId;
command.Parameters.Add("@din", NpgsqlDbType.Date).Value = dateIn;
command.Parameters.Add("@dout", NpgsqlDbType.Date).Value = dateOut;
then I open the connection and execute the command:
conn.openConnection();
if (command.ExecuteNonQuery() == 1)
But I get an error.
column "cnumberclient" doesn't exist
Postgres doesn't seem to see the parameters Can you help me?