In order to improve the decoding efficiency of error correct codes, a method based on Grbner bases for modules was presented for solving the key equation in decoding error correct codes so as to find the error location and error patterns. In the decoding, the problem of solving key equations was transformed to the computation of Grbner bases in different partial order. Then, the polynomials of error locations and error patterns can be computed out by the conversion of two Grbner bases in different order. In this method, error locator and error evaluator polynomials can be found simultaneously. Meanwhile, it is a general algorithm for decoding binary and nonbinary cyclic code. This method can be up to the true minimum distance of designed decoding method.