I am trying to check if an update was successful in ItemUpdated of a formview.
if (e.Exception == null)
{
if (e.AffectedRows == 1)
{
...
...
}
else
{
always ends up here
}
}
else
{
....
}
I keep getting affetcedRows as -1 even though when I trace the update query it processes correctly (no exception) and when I check the database the record is updated
<asp:FormView
runat="server"
ID="fvLogDetail"
DefaultMode="Insert"
DataSourceID="odsDetail"
OnDataBound="fvLogDetail_DataBound"
OnItemInserting="fvLogDetail_ItemInserting"
OnItemUpdating="fvLogDetail_ItemUpdating"
OnItemInserted="fvLogDetail_ItemInserted"
OnItemUpdated="fvLogDetail_ItemUpdated"
OnItemDeleted="fvLogDetail_ItemDeleted">
protected void fvLogDetail_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
{
if (e.Exception == null)
{
if (e.AffectedRows == 1)
{
}
else
{
It always end up here even on successful updates
I must add that the formview is inside an update panel.
NoBullMan
Participant
1022 Points
788 Posts
FormView.ItemUpdated problem
May 03, 2012 05:17 PM|LINK
I am trying to check if an update was successful in ItemUpdated of a formview.
if (e.Exception == null) { if (e.AffectedRows == 1) { ... ... } else { always ends up here } } else { .... }I keep getting affetcedRows as -1 even though when I trace the update query it processes correctly (no exception) and when I check the database the record is updated
formview
sreejukg
All-Star
28153 Points
4212 Posts
Re: FormView.ItemUpdated problem
May 03, 2012 05:28 PM|LINK
Do you have Set NoCount On in the SQL Statement?
http://www.dotnetfunda.com/interview/exam2449-what-is-the-use-of-set-nocount-on-in-sql-server.aspx
My Blog
NoBullMan
Participant
1022 Points
788 Posts
Re: FormView.ItemUpdated problem
May 03, 2012 06:29 PM|LINK
I am using Oracle database. The SQL statement is just a regular, run of the mill update statement. Do I need to set NOCOUNT=OFF, like
string sQuery = "NOCOUNT=OFF;update table set ....;")
NoBullMan
Participant
1022 Points
788 Posts
Re: FormView.ItemUpdated problem
May 03, 2012 07:09 PM|LINK
I found out that Oracle does not have a NOCOUNT ON/OFF, it uses SET FEEDBACK ON/OFF. In any case, if I include this in my SQL statement, it barfs!
string sQuery = "begin set feedback on; update table ....;end;"
asp.netx.0lo...
Member
362 Points
71 Posts
Re: FormView.ItemUpdated problem
May 07, 2012 09:53 AM|LINK
Can you show me your .aspx file with simplified sample?
Based on my experience, there is something wrong there.
I'm here because of your another post.
formview
NoBullMan
Participant
1022 Points
788 Posts
Re: FormView.ItemUpdated problem
May 08, 2012 06:42 PM|LINK
<asp:FormView runat="server" ID="fvLogDetail" DefaultMode="Insert" DataSourceID="odsDetail" OnDataBound="fvLogDetail_DataBound" OnItemInserting="fvLogDetail_ItemInserting" OnItemUpdating="fvLogDetail_ItemUpdating" OnItemInserted="fvLogDetail_ItemInserted" OnItemUpdated="fvLogDetail_ItemUpdated" OnItemDeleted="fvLogDetail_ItemDeleted"> protected void fvLogDetail_ItemUpdated(object sender, FormViewUpdatedEventArgs e) { if (e.Exception == null) { if (e.AffectedRows == 1) { } else { It always end up here even on successful updatesI must add that the formview is inside an update panel.
formview