SAlvarez208274 (Community Member) asked a question.

Good Morning,

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();

   }

 }


Topics (3)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.