CodeIgniter Forums
How to get data from mssql with ci - 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: How to get data from mssql with ci (/showthread.php?tid=36326)



How to get data from mssql with ci - El Forum - 11-28-2010

[eluser]Unknown[/eluser]
halo..

i need help in connecting mssql with code igniter...

i have set the setting in database.php correctly..

and every thingelse..

can anybody please give me a guide how to connect to mssql 2000?

how i tried to find in the net but i recognised that none is helpfull...please help me..

thank u....


How to get data from mssql with ci - El Forum - 11-28-2010

[eluser]CI_adis[/eluser]
hi,

I have the same problem that is driving me crazy!

if i try through ADOBDB then it works:

Code:
$myServer = "localhost";
$myUser = "demo";
$myPass = "demo)!";
$myDB = "demo";

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer");

//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
  or die("Couldn't open database $myDB");

//declare the SQL statement that will query the database
$query = "SELECT syscode, naam ";
$query .= "FROM cars ";

//execute the SQL query and return records
$result = mssql_query($query);

$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";

//display the results
while($row = mssql_fetch_array($result))
{
  echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>";
}
//close the connection
mssql_close($dbhandle);

but when i configure it in CI it is not working:

database.php:

Code:
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "demo";
$db['default']['password'] = "demo)!";
$db['default']['database'] = "";
$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 I call it in my controller:

Code:
$this->load->database();

but i still get the error message:

Error Summary
HTTP Error 500.0 - Internal Server Error


How to get data from mssql with ci - El Forum - 11-30-2010

[eluser]CI_adis[/eluser]
no one faced this one?

Please advise how to solve or try to solve...


How to get data from mssql with ci - El Forum - 12-01-2010

[eluser]Unknown[/eluser]
hai...

try to changing the hostname with="127.0.0.1"..

before that what server are u using?

me myself using xampp(apache)..

how about u?

i was able to figure out my problem.


How to get data from mssql with ci - El Forum - 12-02-2010

[eluser]CI_adis[/eluser]
Hi Mansoor,
I have tried:

Code:
localhost
and
127.0.0.1
and
<PC_Name>
and
<PC_Name\InstanceName>

but no result.. only a white page instead of the HTTP error message..

I also tried updating the ntwdblid.dll.
I also tried another version of php but no result.. perhaps it is the MSSQL 2008 R2?
I will try this weekend with MSSQL 2005.

I'm using WAMP 2.0i.

Regards,


How to get data from mssql with ci - El Forum - 12-14-2010

[eluser]cool248[/eluser]
soory for my late reply...

please open the connection ini php.ini file..

1,open the connection in php.ini file
2.make sure to the localhost connection with 127.0.0.1
3.change the dbdriver to mssql.
4.enjoy!!!

ini mine is it is working perfectly..

one more thing for the php.ini file it is in the webserver's folder.so it is like this [your webserver folder]==>[php]==>[php.ini]

after that ini the line 967.u have to delete the semicolon which is in front of that extension.

extension=php_mssql.dll <== 'This one'...

try it..