Welcome Guest, Not a member yet? Register   Sign In
Unable to connect to MSSQL database locate at different machine
#1

[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
#2

[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());
#3

[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'] = "";
#4

[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??
#5

[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 ?
#6

[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
#7

[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 ?
#8

[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)
#9

[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.




Theme © iAndrew 2016 - Forum software by © MyBB