i'm trying insert row in postgresql table date column. on ui, got datetimepicker user selectes proper date. far got this:
on ui:
objpresupuesto.date = this.dtpfechapres.value.tostring("yyyy-mm-dd");
on method inserts row:
npgsqlcommand query = new npgsqlcommand("insert presupuesto(presupuesto, codigo, descripcion, fecha, cliente, proyecto, total) values(nextval('presupuesto_presupuesto_seq'), @codigo, @descripcion, @fecha, @cliente, @proyecto, @total);select lastval();", conn); ... query.parameters.add(new npgsqlparameter("fecha", npgsqldbtype.date, 0, "fecha")); ... query.parameters[2].value = obj.date.tostring;//without tostring fails
it throws exception:
specified cast not valid.
the obj.date value 2011-04-29. tryied putting single quotes around, fails.
the database column type date.
anyone has done before? ideas?
i checked link searching , aswer doesn't helped. thanks
the first thing noticed when adding parameter missing "@" beginning command references value "@".
are sure parameters[2] "fecha" parameter?
Comments
Post a Comment