I have this error Another SqlParameterCollection already contains SqlParameter.

Last Reply 8 days ago By dharmendr

Posted 8 days ago
I have this error Another SqlParameterCollection already contains SqlParameter.
 
I tried whit sqlparameter.Clear(); but it does not work
 
This is my method code
        public static List<string> obtenerDatos(string itemID)
        {
            List<string> r = new List<string>();
            try
            {
                //StringBuilder sQuery = new StringBuilder();
                //sQuery.Append("SELECT ItemName ");
                //sQuery.Append("FROM INVENTTABLE A ");
                //sQuery.Append("WHERE A.DATAAREAID = 'sgp' ");
                //sQuery.Append("AND A.ItemId = @ItemID ");
                //sQuery.Append("AND A.MODULETYPE = 0"); //Moulo de Inventario 
                string qwery = @"SELECT * FROM INVENTTABLE A WHERE A.DATAAREAID = 'rrp' AND A.ItemId = @ItID AND A.MODULETYPE = 0";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@ItemID", itemID.Trim());
                using (DataTable dt = DBConnection.DoSQL(qwery.ToString(), parameters))
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        r = (List<string>)row["ItemName"];
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Error al obtener los articulos", ex);
            }
            return r;
        }

 

You are viewing reply posted by: dharmendr 8 days ago.