I use many transaction in my project : Like this :
bool retVal = true;
string errorCode = string.Empty;
try
{
result = RecordsDal.ReadAllDoneRecords();
retVal = Export(result, out errorCode);
}
catch
{
Errorlog(errorCode, ex.Message);
MessageBox.Show("Error Export "+ Environment.NewLine + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return false;
}
the export :
public static bool Export(List<Record> result, out string error)
{
bool retVal = true;
error = "sqlCeConnection";
SqlCeConnection sqlCeConnection = null;
error = "Initializiong";
SqlTransaction trans = null;
try
{
error = "Begin";
.......
error = "End";
}
catch (Exception ex)
{
trans.Rollback();
retVal = false;
}
}
and I use an error logs to Know where I have a problem,
the application work fine in many client but I install the app in the new one and I have an error with the file log have the code error and the exception ex.Message
Initializing : Object reference not set to an instance of an object
the error in this line : SqlTransaction trans = null;
sorry, I found the real problem, the sqlCe not installed, and there’s ex.innerexception = null the the log have save this error not the real one
sorry, I found the real problem, the sqlCe not installed, and there’s ex.innerexception = null the the log have save this error not the real one