CodeIgniter Forums
Unable to connect to MSSQL database locate at different machine - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Unable to connect to MSSQL database locate at different machine (/showthread.php?tid=5501)



Unable to connect to MSSQL database locate at different machine - El Forum - 01-23-2008

[eluser]vinci777[/eluser]
I have a web application which need to connect to MS SQL database...previously the database locate at the localhost, everything works perfectly. But now i have move the database to the other machine...i connect to the database using IP or the machine name, then i get this error message



An Error Was Encountered
Unable to connect to your database server using the provided settings.




Anyone know how to solve this problem??...or is CI only able to connect to localhost database only??

pls help...thanks a lot


Unable to connect to MSSQL database locate at different machine - El Forum - 01-23-2008

[eluser]Seppo[/eluser]
I don´t think it´s a CI problem... try to connect to DB using a simplier PHP script
Code:
mssql_connect('myhost','myuser','mypass') or die(mssql_get_last_message());



Unable to connect to MSSQL database locate at different machine - El Forum - 01-23-2008

[eluser]vinci777[/eluser]
In my database.php, below is the code...should be no problem right??

Code:
$active_group = "default";

$db['default']['hostname'] = "DELL505\SQLEXPRESS";
$db['default']['username'] = "sa";
$db['default']['password'] = "password";
$db['default']['database'] = "MyDatabase";
$db['default']['dbdriver'] = "mssql";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";



Unable to connect to MSSQL database locate at different machine - El Forum - 01-23-2008

[eluser]vinci777[/eluser]
[quote author="Seppo" date="1201166663"]I don´t think it´s a CI problem... try to connect to DB using a simplier PHP script
Code:
mssql_connect('myhost','myuser','mypass') or die(mssql_get_last_message());
[/quote]

this Php works...able to connect to the database...but how come CI is not working??

keep showing the same error msg??


Unable to connect to MSSQL database locate at different machine - El Forum - 02-26-2008

[eluser]Andi Eko[/eluser]
I have the same problem.
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "169.254.216.4";
$db['default']['username'] = "sa";
$db['default']['password'] = "password";
$db['default']['database'] = "Billing";
$db['default']['dbdriver'] = "mssql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

And here the error :

An Error Was Encountered

Unable to connect to your database server using the provided settings.

I'm not try to connect manually, I just use this code :

$this->load->database();

It doesn't work ? any solution ?


Unable to connect to MSSQL database locate at different machine - El Forum - 02-26-2008

[eluser]vinci777[/eluser]
[quote author="Andi Eko" date="1204037609"]I have the same problem.
$active_group = "default";
$active_record = TRUE;

$db['default']['hostname'] = "169.254.216.4";
$db['default']['username'] = "sa";
$db['default']['password'] = "password";
$db['default']['database'] = "Billing";
$db['default']['dbdriver'] = "mssql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

And here the error :

An Error Was Encountered

Unable to connect to your database server using the provided settings.

I'm not try to connect manually, I just use this code :

$this->load->database();

It doesn't work ? any solution ?[/quote]




i found the problem...~it is because of the version of the MSSQL.... mine is MSSQL 2005...i tested in a few pc with the MSSQL 2000 then can connect edi...

read up a few forum...PHP have some limitations or bug connecting to MSSQL 2005....i guess so


Unable to connect to MSSQL database locate at different machine - El Forum - 02-26-2008

[eluser]Andi Eko[/eluser]
Mine is MSSQL2000
when I change into odbc I can connect when I load the database. But when I try to get the table I've got an error like this :
Fatal error: Call to a member function get() on a non-object in D:\CodeI\system\application\controllers\blog.php on line 7
=====
I still can't figure it out whats wrong with this connection.
========
Any idea ?


Unable to connect to MSSQL database locate at different machine - El Forum - 02-26-2008

[eluser]Seppo[/eluser]
It seems link ActiveRecord is disabled... Do you have
Code:
$active_record = TRUE;

in you application/config/database.php file? (It has changed on CI 1.6 or 1.6.1)


Unable to connect to MSSQL database locate at different machine - El Forum - 02-26-2008

[eluser]Andi Eko[/eluser]
I've already activated the $active_record I use CI 1.6.1 but still doesn't work.
Right now I can load database with autoload.php and still cannot get the result.