• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Codeigniter, sql server 2008, php 5.3.5

#1
[eluser]Unknown[/eluser]
Hello,

I have a problem with my application, i can't connect to sql server 2008 with mssql driver after many research on the web still no response to that probleme. No error message, i have got an empty page.

i have a sql user for the database i dont think that's the problem.

thank's to your help!!!

#2
[eluser]mobs6[/eluser]
first of all try check again...have u load your DB in your controller or auto load config.
second, your DB CONFIG must do something like this, this is my cofiguration for 2 MSSQL 2008 DB:

$active_group = 'DB2';
$active_record = FALSE;
$db['DB2']['hostname'] = "192.168.11.20";
$db['DB2']['port'] = 1433; //--> config using DB port, must Use DB PORT
$db['DB2']['username'] = "user2";
$db['DB2']['password'] = "password2";
$db['DB2']['database'] = "DB2";
$db['DB2']['dbdriver'] = "mssql";

$db['DB2']['dbprefix'] = '';
$db['DB2']['pconnect'] = FALSE; //Turn OFF
$db['DB2']['db_debug'] = TRUE;
$db['DB2']['cache_on'] = FALSE;
$db['DB2']['cachedir'] = '';
$db['DB2']['char_set'] = 'utf8';
$db['DB2']['dbcollat'] = 'utf8_general_ci';
$db['DB2']['swap_pre'] = '';
$db['DB2']['autoinit'] = FALSE;
$db['DB2']['stricton'] = FALSE;

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = "192.168.11.1,1433"; //--> must use DB port, without config
$db['default']['username'] = "user1";
$db['default']['password'] = "password1";
$db['default']['database'] = "DB1";
$db['default']['dbdriver'] = "mssql";

$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE; //Turn off
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

Note: the default port MSSQL is 1433

in your constructor model or controller just load your DB like this:
$DB1=$this->load->db->('default',TRUE);
$DB2=$this->load->db->('DB2',TRUE);


then u could try to use it like this:
public function forDB1() {
$result=$this->DB1->query->("select * from tbl")->result();
return $result;
}
public function forDB2() {
$result=$this->DB2->query->("select * from tbl")->result();
return $result;
}






Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.