Beginner here:
In this answer to my question of how to insert data into SQL Server he mentioned passing parameters instead of string concatenation like I currently
Here is an example:
SqlConnection myConn = new SqlConnection("my connection string");
SqlCommand myCmd = new SqlCommand("myStoredProcName", myConn);
myCmd.CommandType = CommandType.StoredProcedure;
myCmd.Parameters.AddWithValue("@cGroupID", 0).Direction = ParameterDirection.InputOutput;
myCmd.Parameters.AddWithValue("@gType", "C");
myCmd.Parameters.AddWithValue("@requirement", "Y");
myCmd.Parameters.AddWithValue("@usercode", "XX");
myConn.Open();
myCmd.ExecuteNonQuery();
int covID = (int)myCmd.Parameters["@cGroupID"].Value;
Using Parameters is a good way to prevent some errors, and help stop injection vectors. It also allows OUTPUT parameters, as in the example above where cGroupID comes back with a value that I can access.