[eluser]InsiteFX[/eluser]
You say your getting an error but you have not post what the error is that your getting!
Also it's best to autoload the database in ./application/config/autoload.php
Then you can just get the CI instance and do a $this->CI->db