Click here to Skip to main content
15,883,969 members
Home / Discussions / C#
   

C#

 
GeneralRe: Convert Properties in vb6 to C# Pin
Jimmy Beh1-Apr-14 20:28
Jimmy Beh1-Apr-14 20:28 
AnswerRe: Convert Properties in vb6 to C# Pin
Bernhard Hiller1-Apr-14 20:54
Bernhard Hiller1-Apr-14 20:54 
Questionhow can i connect to microsoft access database Pin
Member 104662021-Apr-14 9:23
Member 104662021-Apr-14 9:23 
AnswerRe: how can i connect to microsoft access database Pin
Kornfeld Eliyahu Peter1-Apr-14 11:05
professionalKornfeld Eliyahu Peter1-Apr-14 11:05 
AnswerRe: how can i connect to microsoft access database Pin
Sivaraman Dhamodharan1-Apr-14 19:14
Sivaraman Dhamodharan1-Apr-14 19:14 
AnswerRe: how can i connect to microsoft access database Pin
V.2-Apr-14 2:01
professionalV.2-Apr-14 2:01 
AnswerRe: how can i connect to microsoft access database Pin
Hexa How2-Apr-14 20:41
Hexa How2-Apr-14 20:41 
QuestionMultiple try blocks in c# 2.0 Pin
ramki481-Apr-14 2:35
ramki481-Apr-14 2:35 
For you all, "if one method throws an exception, the other methods will not run." this is the main reason I am using separate try..catch blocks. So that, even if a function gives an exception, the next can execute.

Can you suggest me a nice approach other than I am using here to execute the next function even if an exception occurred during the first function.

My Code

public XmlDocument GetXML(string[] arrInputInfo)
{
string rtnErrno=null;
ArrayList rtnValidateLogin=null;
string rtnPostSMS = null;
string strStartDateTime = DateTime.Now.ToString();
string strEndDateTime = DateTime.Now.ToString();
DataSet dst=new DataSet();
string[] arrLogReq = new string[5];
string strLoginRef = "-999";
string strstatus = "20";



try
{
//Validate Input Details
rtnErrno = ValidateInputInfo(arrInputInfo);

if (rtnErrno != "0")
{
throw new Exception("Exception raised at Input Validation");
}
//Validate Login Details
rtnValidateLogin = objLogin.ValidateCPLogin(arrInputInfo[0], arrInputInfo[1]);

if (rtnValidateLogin[0].ToString() != "0")
{
rtnErrno = rtnValidateLogin[0].ToString();
throw new Exception("Exception raised at Login Validation");
}
else
{
dst = (DataSet)rtnValidateLogin[1];
strLoginRef = dst.Tables[0].Rows[0][0].ToString();
}

//Insert Message
rtnPostSMS = PostSMSText(arrInputInfo);

if (rtnPostSMS.ToString() != "0")
{
rtnErrno = rtnPostSMS[0].ToString();
throw new Exception("Exception raised at Inserting Message");
}


}
catch (Exception ex)
{
strstatus = "30";
LogErrorHelper.LogError(Constants.ERROR_WEBSERVICES_LOGFILE, ex, "BLL.CSMSService-->GetXML");
}
finally
{
GC.Collect();
}


try
{
strEndDateTime = DateTime.Now.ToString();
arrLogReq[0] = strLoginRef; //Login Ref no
arrLogReq[1] = string.Concat(arrInputInfo[2], "~", arrInputInfo[3]); //Mobile No and Message
arrLogReq[2] = strStartDateTime; //start time
arrLogReq[3] = strEndDateTime; //end time
arrLogReq[4] = strstatus;
//To Log Incoming Requests
rtnErrno = LogConfirmation(arrLogReq);
}
catch (Exception ex)
{
LogErrorHelper.LogError(Constants.ERROR_WEBSERVICES_LOGFILE, ex, "BLL.CSMSService-->GetXML");
}
finally
{
GC.Collect();
}
return GetFinalXml(rtnErrno);
}
AnswerRe: Multiple try blocks in c# 2.0 Pin
Eddy Vluggen1-Apr-14 3:04
professionalEddy Vluggen1-Apr-14 3:04 
GeneralRe: Multiple try blocks in c# 2.0 Pin
OriginalGriff1-Apr-14 4:47
mveOriginalGriff1-Apr-14 4:47 
GeneralRe: Multiple try blocks in c# 2.0 Pin
Rob Philpott1-Apr-14 5:18
Rob Philpott1-Apr-14 5:18 
GeneralRe: Multiple try blocks in c# 2.0 Pin
OriginalGriff1-Apr-14 5:38
mveOriginalGriff1-Apr-14 5:38 
GeneralRe: Multiple try blocks in c# 2.0 Pin
Rob Philpott1-Apr-14 5:46
Rob Philpott1-Apr-14 5:46 
GeneralRe: Multiple try blocks in c# 2.0 Pin
Eddy Vluggen1-Apr-14 6:44
professionalEddy Vluggen1-Apr-14 6:44 
GeneralRe: Multiple try blocks in c# 2.0 Pin
Rob Philpott1-Apr-14 6:51
Rob Philpott1-Apr-14 6:51 
GeneralRe: Multiple try blocks in c# 2.0 Pin
Eddy Vluggen1-Apr-14 9:11
professionalEddy Vluggen1-Apr-14 9:11 
GeneralRe: Multiple try blocks in c# 2.0 Pin
Eddy Vluggen1-Apr-14 6:56
professionalEddy Vluggen1-Apr-14 6:56 
GeneralRe: Multiple try blocks in c# 2.0 Pin
OriginalGriff1-Apr-14 7:56
mveOriginalGriff1-Apr-14 7:56 
GeneralRe: Multiple try blocks in c# 2.0 Pin
BobJanova1-Apr-14 23:29
BobJanova1-Apr-14 23:29 
AnswerRe: Multiple try blocks in c# 2.0 Pin
Deflinek1-Apr-14 5:15
Deflinek1-Apr-14 5:15 
GeneralRe: Multiple try blocks in c# 2.0 Pin
OriginalGriff1-Apr-14 8:25
mveOriginalGriff1-Apr-14 8:25 
GeneralRe: Multiple try blocks in c# 2.0 Pin
Deflinek1-Apr-14 23:51
Deflinek1-Apr-14 23:51 
GeneralRe: Multiple try blocks in c# 2.0 Pin
OriginalGriff2-Apr-14 0:04
mveOriginalGriff2-Apr-14 0:04 
AnswerRe: Multiple try blocks in c# 2.0 Pin
GuyThiebaut2-Apr-14 2:20
professionalGuyThiebaut2-Apr-14 2:20 
QuestionHow to check a field/property is existing in Win32_DiskDrive ? Pin
taibc1-Apr-14 0:30
taibc1-Apr-14 0:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.