Hi! it's my first time here but I hope someone can help me with this issue I've been trying to resolve the past 2 days: I'm just updating a table with a single query, the connection is fine and the ExecuteNonQuery returns 2 (and it's correct, the number
of rows updated) but consulting the database using SQLServer... there's no change!!! This happen if I deploy the solution (an mobile application) and let it run normally, but if I debugg... the table is updated!!!! I've tried so many things... any idea? (The
connection is already open) Part of the code is:
string query = "UPDATE demandUp SET dmdSent = 1 WHERE dmdHold = 0"
if (ejecutarQuery(query))
{
GlobalesCommon.errores.mostrar(GlobalesCommon.wcGENERAL, Error.ERROR_SAVE_TABLE, "demandUp");
return false;
}
Where ejecutarQuery is:
SqlCeCommand cmdQuery = new SqlCeCommand();
if (tipoConexion == GlobalesCommon.SQL_CONNECTION1)
cmdQuery = new SqlCeCommand(query, pConnection);
else//SQL_CONNECTION2
cmdQuery = new SqlCeCommand(query, pConnection2);
Create log file, and log all information like Connection string used, result return by execute non query, Exceptions in catch block..This information might help for analysing the issue.
Thanks,
Ganesh Rane
Don't forget to mark useful responses as Answer if they helped you towards a solution.
Thank you for respond... I resolved it... it was the flush interval, the ExecuteNonQuery return a value so there was a problem with the commit. I put on the string connection Flush Interval = 1 cause the default value is 10 seconds, and apply a thread.sleep
(2000). With that there was a chance to let the mobile application save the data on the disk... but thank you anyway!
RosBlanc
0 Points
2 Posts
ExecuteNonQuery return value but doesn't update c#
Aug 01, 2012 02:31 PM|LINK
Hi! it's my first time here but I hope someone can help me with this issue I've been trying to resolve the past 2 days: I'm just updating a table with a single query, the connection is fine and the ExecuteNonQuery returns 2 (and it's correct, the number of rows updated) but consulting the database using SQLServer... there's no change!!! This happen if I deploy the solution (an mobile application) and let it run normally, but if I debugg... the table is updated!!!! I've tried so many things... any idea? (The connection is already open) Part of the code is:
string query = "UPDATE demandUp SET dmdSent = 1 WHERE dmdHold = 0"
if (ejecutarQuery(query))
{
GlobalesCommon.errores.mostrar(GlobalesCommon.wcGENERAL, Error.ERROR_SAVE_TABLE, "demandUp");
return false;
}
Where ejecutarQuery is:
SqlCeCommand cmdQuery = new SqlCeCommand();
if (tipoConexion == GlobalesCommon.SQL_CONNECTION1)
cmdQuery = new SqlCeCommand(query, pConnection);
else//SQL_CONNECTION2
cmdQuery = new SqlCeCommand(query, pConnection2);
cmdQuery.CommandType = CommandType.Text;
try
{
cmdQuery.ExecuteNonQuery();
cmdQuery.Dispose();
return true;
}
catch (System.Data.SqlServerCe.SqlCeException ex)
{
foreach (System.Data.SqlServerCe.SqlCeError error in ex.Errors)
MessageBox.Show(error.ToString(), GlobalesCommon.AppName);
cmdQuery.Dispose();
return false;
}
Thanks!
ganesh.rane
Participant
1854 Points
318 Posts
Re: ExecuteNonQuery return value but doesn't update c#
Aug 01, 2012 02:58 PM|LINK
Ganesh Rane
Don't forget to mark useful responses as Answer if they helped you towards a solution.
RosBlanc
0 Points
2 Posts
Re: ExecuteNonQuery return value but doesn't update c#
Aug 01, 2012 10:25 PM|LINK
Thank you for respond... I resolved it... it was the flush interval, the ExecuteNonQuery return a value so there was a problem with the commit. I put on the string connection Flush Interval = 1 cause the default value is 10 seconds, and apply a thread.sleep (2000). With that there was a chance to let the mobile application save the data on the disk... but thank you anyway!