CodeIgniter Forums
Trouble connecting to MS SQL Server 2000 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Trouble connecting to MS SQL Server 2000 (/showthread.php?tid=18281)



Trouble connecting to MS SQL Server 2000 - El Forum - 04-30-2009

[eluser]HDuqueC[/eluser]
Hi to all,

I'm doing something wrong but I can't realize what it is!. I have a simple PHP script like this, that runs fine:

<?php
$myServer = "mysrvr";
$myUser = "myuser";
$myPass = "mypass";
$myDB = "mydatabase";
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$conn->open($connStr);
...etc...etc...
?>

I'm trying to connect using CI but always fails:

In my database.php :

$db['default']['hostname'] = "mysrvr";
$db['default']['username'] = "myuser";
$db['default']['password'] = "mypass";
$db['default']['database'] = "mydatabase";
$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";

But in my controller the line
$this->load->database();
Raises connection fails.

What am I doing wrong? Any help will be appreciated.

Nando.


Trouble connecting to MS SQL Server 2000 - El Forum - 05-01-2009

[eluser]cwt137[/eluser]
Codeigniter uses the mssql extension. Make sure you have the mssql PHP extension installed. You can check this by looking at the output of phpinfo().


Trouble connecting to MS SQL Server 2000 - El Forum - 05-02-2009

[eluser]HDuqueC[/eluser]
Thank you for your post.

[quote author="cwt137" date="1241208412"]Codeigniter uses the mssql extension. Make sure you have the mssql PHP extension installed. You can check this by looking at the output of phpinfo().[/quote]

Runing phpinfo() I found mssql running with theese parameters:

Library version : 7.0
mssql.allow_persistent: On
mssql.batchsize: 0
mssql.compatability_mode: Off
mssql.connect_timeout: 5
mssql.datetimeconvert: On
mssql.max_links: Unlimited
mssql.max_persistent: Unlimited
mssql.max_procs: Unlimited
mssql.min_error_severity: 10
mssql.min_message_severity: 10
mssql.secure_connection: Off
mssql.textlimit: Server default
mssql.textsize: Server default
mssql.timeout: 60

Maybe should I change any parameter?


Trouble connecting to MS SQL Server 2000 - El Forum - 05-05-2009

[eluser]cwt137[/eluser]
The default settings should be ok. How about creating a simple script like this one, http://us.php.net/manual/en/function.mssql-query.php , to see if the mssql module works. If it works, then you know it is something wrong with the way you setup CI. Also, for the server name, use a real host name or the IP address of the database server.


Trouble connecting to MS SQL Server 2000 - El Forum - 05-06-2009

[eluser]HDuqueC[/eluser]
Thank you for your help.

I already solved the question and I'll like to share this link http://www.akamarketing.com/blog/99-php-sql-server-connection-problems-mssql_connect-functionmssql-connect-unable-to-connect-to-server.html with anyone who read this thread.

Nando.