CodeIgniter Forums

Full Version: Error connecting to SQL Server
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

El Forum

[eluser]hsdell[/eluser]
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:
Code:
$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'] = "";
Controller:
Code:
class Org3 extends Controller {

    function Org3()
    {
         parent::Controller();      
         $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:
Code:
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!

Thanks.

El Forum

[eluser]Sawariya[/eluser]
Your database config is corrrect..
you check your DSN setting...

El Forum

[eluser]hsdell[/eluser]
Hi Sawariya,

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

Thanks.

El Forum

[eluser]Sawariya[/eluser]
$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

El Forum

[eluser]hsdell[/eluser]
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.

El Forum

[eluser]Sawariya[/eluser]
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..

El Forum

[eluser]Pascal Kriete[/eluser]
Make sure you're loading the database class.
Code:
$this->load->database();

El Forum

[eluser]hsdell[/eluser]
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?

El Forum

[eluser]Sawariya[/eluser]
not problem with your code...
i am sure that your database not connecting....

El Forum

[eluser]ELRafael[/eluser]
hsdell:

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

Code:
$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?
Pages: 1 2