
SAlvarez208274 (Community Member) asked a question.
I'm experiencing constant CWE-89 errors no matter how I refactor the following code(in details) especially this line get's flagged (the fill):
sqlAdpt.Fill(dtblData);
Please advise how to fix so that Veracode doesn't flag it.
public DataTable GetFYLocationsBySystemID(string query, ref string strErrorMsg)
{
SqlConnection sqlCon = new SqlConnection();
SqlDataAdapter sqlAdpt = new SqlDataAdapter();
SqlCommand sqlComm = new SqlCommand();
DataTable dtblData = new DataTable();
try
{
sqlCon = new SqlConnection(_strSqlString);
sqlComm = new SqlCommand(query, sqlCon);
sqlComm.CommandType = CommandType.Text;
sqlAdpt.SelectCommand = sqlComm;
sqlAdpt.Fill(dtblData);
return dtblData;
}
catch (Exception ex)
{
strErrorMsg = ex.Message;
return null;
}
finally
{
sqlCon.Close();
sqlCon.Dispose();
sqlComm.Dispose();
}
}
.png)