The result of a search at the LHC for heavy stable charged particles produced in pp collisions at sqrt(s) = 7 TeV is described. The data sample was collected with the CMS detector and corresponds to an integrated luminosity of 3.1 inverse picobarns. Momentum and ionization-energy-loss measurements in the inner tracker detector are used to identify tracks compatible with heavy slow-moving particles. Additionally, tracks passing muon identification requirements are also analyzed for the same signature. In each case, no candidate passes the selection, with an expected background of less than 0.1 events. A lower limit at the 95% confidence level on the mass of a stable gluino is set at 398 GeV/c^2, using a conventional model of nuclear interactions that allows charged hadrons containing this particle to reach the muon detectors. A lower limit of 311 GeV/c^2 is also set for a stable gluino in a conservative scenario of complete charge suppression, where any hadron containing this particle becomes neutral before reaching the muon detectors.