Welcome Guest, Not a member yet? Register   Sign In
HELP: db-connection settings for ODBC to MSSQL
#11

[eluser]Unknown[/eluser]
[quote author="Elminson" date="1269473410"]i use this lines to connect a remote ms Sql Server using odbc and work perfect!!!!

on database.php config

$db['default']['hostname'] = "Driver={SQL Server Native Client 10.0};Server=remote_host_name;Database=database_name;";
$db['default']['username'] = "database_user_name";
$db['default']['password'] = "database_password";
$db['default']['database'] = "database_name";
$db['default']['dbdriver'] = "odbc";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

i hope this help you[/quote]


Thanks mate, this worked perfectly for me connecting to MS SQL 2008 server.

Edit: whoops, March 2 years ago, not 2 days ago.. sorry for the dig.. oh well, it was useful information for me anyway as I was having trouble figuring out how to get MS SQL working Smile
#12

[eluser]feroy[/eluser]
Hi, brothers.

I am trying to connect mysql via odbc. Can you give me configuration on database.php to be able to connect to mysql?

I don't really know what should i put in the $db['default']['hostname'], so i can connect it to mysql.

Thanks for the help.
#13

[eluser]sunil shrestha[/eluser]
I have also connect codeigniter and odbc using DSN Name. But there is some bugs with this driver while using ACTIVE RECORDS.... You should hard code the sql query. for example.. using active records for odbc, it add the bracket to the table name which is not executed for MS sql server. It shows errors like below:
A Database Error Occurred

Error Number: 37000

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'.

SELECT * FROM (ci_sessions) WHERE session_id = '3ad914bb5f5728e8ac69ad1db8fc9841' AND user_agent = 'Mozilla/5.0 (Windows NT 6.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2'

Filename: D:\wamp\www\IVR_Panel\system\database\DB_driver.php

Line Number: 330


The following are the config file for connecting odbc for MS SQL SERVER

Code:
$db['default']['hostname'] = 'IVR';   // DSN Name created in odbc of administrative tools of // controll panel
$db['default']['username'] = 'dbusername';   // user name of database
$db['default']['password'] = 'dbpassword';   //password of database
$db['default']['database'] = 'dbname';       // database name to connect
$db['default']['dbdriver'] = 'odbc';         // odbc driver name
$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';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;

above config is enough to connect to odbc but you have creaTE THE dsn in odbc of administrative tool of control panel




Theme © iAndrew 2016 - Forum software by © MyBB