Execution stuck at SqlHelper.ExecuteNonQueryAsync function

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
I am using SQL Helper library to do the update operation in db. library code taken from here https://gist.github.com/imranbaloch/10895917

I debug the code and saw when this line is executed int recsaffected = await SqlHelper.ExecuteNonQueryAsync(connection, CommandType.Text, SQL);

Then execution was stuck there and not progressing to the next line.

I saw data was updated in db, but why were controls not going to next line. Please help me if I've made any mistakes in the code.

See my code

public async Task<ResponseContext> UpdateStatus(string downloaddate, string listOfID)
{
string SQL = "UPDATE MyTable SET CheckStatus=1 WHERE Convert(varchar,downloaddate,112)=Convert(varchar,'" + downloaddate + "',112) AND ID IN(" + listOfID + ")";
ResponseContext oContext = new ResponseContext();

try
{
var connection = new SqlConnection(ConnectionManager.GetConnectionString());
int recsaffected = await SqlHelper.ExecuteNonQueryAsync(connection, CommandType.Text, SQL);

if (recsaffected > 0)
{
oContext.IsSuccess = true;
oContext.Message = "Models successfuly updated";
oContext.ResponseData = null;
}
else
{
oContext.IsSuccess = false;
oContext.Message = "No records updated ";
oContext.ResponseData = null;
}
}
catch (Exception ex)
{
oContext.IsSuccess = false;
oContext.Message = "Error " + ex.Message.ToString();
oContext.ResponseData = null;
}

return oContext;
}



Calling my function this way.

var task = await _ModelManager.UpdateStatus(Convert.ToString(dtpDate.Value.ToString("yyyy-MM-dd")),listOfID);
ResponseContext oResponseContext = task as ResponseContext;

public class ResponseContext
{
//store true/false as success or fail
public bool IsSuccess { get; set; }
//store success or fail message along with exception text
public string Message { get; set; }
//we can store anything to response data
public object ResponseData { get; set; }
}


please guide me where i have made the mistake in code for which execution stuck on the line


await SqlHelper.ExecuteNonQueryAsync

thanks

Continue reading...
 
Back
Top