Welcome Guest, Not a member yet? Register   Sign In
Error connecting to SQL Server

Hi All,

I'm just getting back to exploring CI after a long hiatus. I had done some stuff last year and was using version 1.3.3 connecting to SQL Server with no problems.

I just added version 1.5.4 and running in parallel with previous version, but I cannot get my new install to work at all with the database or logging (permissions?), while the original work I did works fine with SQL Server. So far, everything else about the new 1.5.4 install works as far as calling controllers, routing, etc.

I have tried using the same db config parms in both:
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "ESCUSER";
$db['default']['password'] = "escuserpwd";
$db['default']['database'] = "wiqe";
$db['default']['dbdriver'] = "odbc";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
class Org3 extends Controller {

    function Org3()
         $this->load->model('Org_model', '', TRUE);

    function index() {

        $data['resultset'] = $this->Org_model->list_all();
        $this->load->view('org_result', $data);    
Works with 1.3.3 installation, and fails with 1.5.4 installation with error:
An Error Was Encountered

Unable to connect to your database server using the provided settings.
I'm thinking something about the drivers has changed between versions and I need to do something else to connect.

Any help will be greatly appreciated!


Your database config is corrrect..
you check your DSN setting...

Hi Sawariya,

Yes, it's the same DSN used in both, same config, both should connect when model is loaded, right?


$db['default']['hostname'] = "localhost";
$db['default']['username'] = "username";
$db['default']['password'] = "password";
$db['default']['database'] = "databasemane";
$db['default']['dbdriver'] = "drivername";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";

i think you are using odbc driver for connecting with sql server..
every thing ok here ...you have to check one more
Check your datasource

Everything tests fine with the DSN.

If there was a problem with the DSN I would not be able to connect with CI 1.3.3.

then some where you would have made some spelling mistake or. something..
check it again..
your config is correct.. and no problem with your DSN also .. coze its working in your older version..

[eluser]Pascal Kriete[/eluser]
Make sure you're loading the database class.

According to the Models section of the manual:

You can tell the model loading function to auto-connect by passing TRUE (boolean) via the third parameter, and connectivity settings, as defined in your database config file will be used:

$this->load->model('Model_name', '', TRUE);

Which is what I'm doing. Is there something wrong with that?

not problem with your code...
i am sure that your database not connecting....


here i'm using ci + mssql, but direct access. I prefer this way

$db['producao']['hostname'] = "prod_machine";
$db['producao']['username'] = "my_user";
$db['producao']['password'] = "my_pass";
$db['producao']['database'] = "notas";
$db['producao']['dbdriver'] = "mssql";
$db['producao']['dbprefix'] = "";
$db['producao']['active_r'] = TRUE;
$db['producao']['pconnect'] = TRUE;
$db['producao']['db_debug'] = TRUE;
$db['producao']['cache_on'] = FALSE;
$db['producao']['cachedir'] = "";

man, works better than odbc. i'm using 1.5.4 version.

is it impossible to you change to mssql driver instead odbc?

Theme © iAndrew 2016 - Forum software by © MyBB