Hi,
have you tried to set NOCOUNT ON/OFF in your SP?
Regards
Olaf
--------------------------------------------------
From: "Eddie" <[email protected]>
Sent: Thursday, June 17, 2010 7:58 PM
To: "nhusers" <[email protected]>
Subject: [nhusers] Re: Update via Stored Procedure
I've tried this
.- adding "select @@rowcount" after update the record in the stored
procedure.
Result: Still geting the error "Batch update returned unexpected
row count from update; actual row count: 0; expected: 1"
.- Using formula in this way
<property name="UpdateDate" type="DateTime" formula="getdate()"
insert="false" >
<column name="last_update_date" sql-type="datetime" not-
null="true" />
</property>
Result: Field "descripcion" is updated (Good)
but field is still null (Bad)
and objeto.UpdateDate = actualDate (Bad, because if a get
the object in other time the properti will be = Now and it is not the
true)
I would really like to sort out the stored procedure issue because I
will need it in more complex enviroments.
Someone has gotten a SP working?
On 17 jun, 12:47, Gianluca Gravina <[email protected]> wrote:
well if you return the rowcount it should wirk, but, as usual, Fabio gave
U
a cleaner and simpler solution !
Try with formula as Fabio suggested !
Gianluca
On Thu, Jun 17, 2010 at 5:44 PM, Eddie <[email protected]> wrote:
> This is my SP
> CREATE PROCEDURE dbo.NHObjetos_Update
> @codigo VARCHAR(5),
> @descripcion VARCHAR(50)
> AS
> UPDATE [NHObjetos] SET [descripcio...@descripcion,
> modificado=GETDATE()
> WHERE [codigo] = @codigo
> GO
> I should return the @@roxcount? using return? or select @@rowcount?
> Can I use the <formula> as follow?
> <property name="UpdateDate" type="DateTime" update="false"
> formula="getdate" insert="false" generated="always" >
> <column name="last_update_date" sql-type="datetime" not-
> null="true" />
> </property>
> On 17 jun, 12:34, Fabio Maulo <[email protected]> wrote:
> > you can use a simple <formula> and generated=always
> > On Thu, Jun 17, 2010 at 11:04 AM, Eddie <[email protected]>
> > wrote:
> > > Hi
> > > I want to update an object using a stored procedure. The reason to
> > > do
> > > this is to update a field 'last_update_date'. So in the sp I set
> > > last_update_date = getdate() because a need to save the server
> > > time.
> > > The problem is I am getting an error when using stored procedure.
> > > Error: "Batch update returned unexpected row count from update;
> > > actual
> > > row count: 0; expected: 1"
> > > If I remove <sql-update > the record is updated but no the field
> > > last_update_date.
> > > How I can solve this error?
> > > There is another way to update this kind of fields?
> > > This is my mapping file:
> > > hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> > > assembly="HP.NHibernate.Framework"
> > > namespace="HP.NHibernate.Framework.Domain">
> > > <class name="Objeto" catalog="Trabajos" schema="dbo"
> > > table="NHObjetos" >
> > > <id name="Codigo" type="String" unsaved-value="">
> > > <column name="codigo" sql-type="varchar" length="5" not-
> > > null="true" unique="true"/>
> > > <generator class="assigned" />
> > > </id>
> > > <property name="Descripcion" type="String">
> > > <column name="descripcion" length="50" sql-type="varchar" not-
> > > null="true" />
> > > </property>
> > > <property name="UpdateDate" type="DateTime" update="false"
> > > insert="false" generated="always" >
> > > <column name="last_update_date" sql-type="datetime" not-
> > > null="true" />
> > > </property>
> > > <sql-update >exec Trabajos.dbo.NHObjetos_Update ?,?
> > > </sql-update>
> > > </class>
> > > </hibernate-mapping>
> > > My code is:
> > > public void UpdateObjeto()
> > > {
> > > using (RepositoryBase repo = new RepositoryBase())
> > > {
> > > try
> > > {
> > > repo.BeginTransaction();
> > > Objeto objeto = (Objeto)
> > > repo.GetById(typeof(Objeto), "DEF45");
> > > objeto.Descripcion = "pepepe";
> > > repo.Update(objeto);
> > > repo.CommitTransaction();
> > > }
> > > catch (Exception ex)
> > > {
> > > repo.RollbackTransaction();
> > > }
> > > }
> > > }
> > > I will apreciate any tip.
> > > Thanks.
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "nhusers" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected]<nhusers%[email protected]
> > > >
> <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup
> s.com>>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/nhusers?hl=en.
> > --
> > Fabio Maulo
> --
> You received this message because you are subscribed to the Google
> Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]
> >
> .
> For more options, visit this group at
>http://groups.google.com/group/nhusers?hl=en.
--
Gianluca Gravinahttp://blogs.ugidotnet.org/thinkingingrava
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.