V
vanvee
Hi
I have the block of code below which is supposed to determine the
number of rows affected with an update statement (ASP.Net, Access, C#,
ADO.Net, OleDB) to determine if the update was successful or if a
concurrency error occurred. There is an enumeration defined called
DBResult where 1 is Success, 2 is ConcurrencyError, and 3 is
DatabaseError. I keep getting a strange behavior on the
ExecuteNonQuery() where it returns 0 sometimes and returns 1 sometimes,
but in all cases it writes to the database correctly. So, I end up
getting a result returned to the user that states concurrency error
(because the reurn from the ExecuteNonQuery is a 0 so the else kicks
in) when the database actually updates correctly (and the result should
be 1)!!!??? There seems to be no reason why it returns inconsistent
results. With the same exact command, sometimes it return 0, sometimes
1, when in all cases 1 row is updated. Any help would be greatly
appreciated.
try
{
if (cmdSources.ExecuteNonQuery() > 0)
{
databaseResult = (int) DBResult.Success;
}
else
{
databaseResult = (int) DBResult.ConcurrencyError;
}
}
catch(Exception e)
{
databaseResult = (int) DBResult.DatabaseError;
}
conSources.Close();
return databaseResult;
I have the block of code below which is supposed to determine the
number of rows affected with an update statement (ASP.Net, Access, C#,
ADO.Net, OleDB) to determine if the update was successful or if a
concurrency error occurred. There is an enumeration defined called
DBResult where 1 is Success, 2 is ConcurrencyError, and 3 is
DatabaseError. I keep getting a strange behavior on the
ExecuteNonQuery() where it returns 0 sometimes and returns 1 sometimes,
but in all cases it writes to the database correctly. So, I end up
getting a result returned to the user that states concurrency error
(because the reurn from the ExecuteNonQuery is a 0 so the else kicks
in) when the database actually updates correctly (and the result should
be 1)!!!??? There seems to be no reason why it returns inconsistent
results. With the same exact command, sometimes it return 0, sometimes
1, when in all cases 1 row is updated. Any help would be greatly
appreciated.
try
{
if (cmdSources.ExecuteNonQuery() > 0)
{
databaseResult = (int) DBResult.Success;
}
else
{
databaseResult = (int) DBResult.ConcurrencyError;
}
}
catch(Exception e)
{
databaseResult = (int) DBResult.DatabaseError;
}
conSources.Close();
return databaseResult;