connect to sql server with sqlsrv - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: connect to sql server with sqlsrv (/showthread.php?tid=78564) Pages:
1
2
|
connect to sql server with sqlsrv - ramin.mor47 - 02-08-2021 Hi, I do not know English. I'm sorry i set config in env but get error "Unable to connect to the database" Do I have to configure it elsewhere with different specifications? help me RE: connect to sql server with sqlsrv - captain-sensible - 02-08-2021 can you elaborate on that IP address your using for hostname; normally thats localhost and yours looks like the IP for a router or something ? Also did you rename env to .env ? RE: connect to sql server with sqlsrv - ramin.mor47 - 02-08-2021 (02-08-2021, 07:21 AM)captain-sensible Wrote: can you elaborate on that IP address your using for hostname; normally thats localhost and yours looks like the IP for a router or something ?Yes I Chenge env to .env Sql server in 192.168.1.4، but my web server in 192.168.1.6 , i cheng Ip 192.168.1.4 to hostname but any difference. is needed install sql server in 192.168.1.6 ? RE: connect to sql server with sqlsrv - captain-sensible - 02-09-2021 this might be relevant ? https://forum.codeigniter.com/thread-75877-post-376318.html#pid376318 you might also try using 192.168.1.4 in dsn at : Code: public $default = [ which is in Database.php in app/config i.e shift from using .env to direct in Database.php i'm no expert on databases; in fact i shifted from main stream database eg MySQl to sqlite3 quite some time ago could you shift to sqlite3 ? works like a dream , all you have to do is put a sqlite3 database file in writable RE: connect to sql server with sqlsrv - ramin.mor47 - 02-09-2021 (02-09-2021, 03:08 AM)captain-sensible Wrote: this might be relevant ? https://forum.codeigniter.com/thread-75877-post-376318.html#pid376318I can Not Chenge Database. If I do not find a solution, I have to go back to the previous version (3). RE: connect to sql server with sqlsrv - paulbalandan - 02-09-2021 Try using 127.0.0.1 as the hostname. If that still fails, check your recent log file in the writable/logs/ folder. Check for the log record with "ERROR -->" RE: connect to sql server with sqlsrv - ramin.mor47 - 02-11-2021 (02-09-2021, 10:16 AM)paulbalandan Wrote: Try using 127.0.0.1 as the hostname. If that still fails, check your recent log file in the writable/logs/ folder. Check for the log record with "ERROR -->"my error log is: Code: ERROR - 2021-02-09 00:38:04 --> Error connecting to the database: Call to undefined function CodeIgniter\Database\SQLSRV\sqlsrv_connect() RE: connect to sql server with sqlsrv - davis.lasis - 02-11-2021 I do use multiple platforms with sqlsrv to connect to axapta database servers. Maybe you need to use single quotes in .env file? This is my code that does work, if this does not work for you, then most probably you have issue with connection IP address and / or DSN .env Code: #-------------------------------------------------------------------- /app/Config/Database.php PHP Code: /** Controller PHP Code: $this->axapta = Database::connect('axapta'); RE: connect to sql server with sqlsrv - paulbalandan - 02-12-2021 Based on your error logs, it seems sqlsrv_connect() is not defined. This means that gou do not have the sqlsrv php extension installed. RE: connect to sql server with sqlsrv - ramin.mor47 - 02-12-2021 (02-12-2021, 05:20 AM)paulbalandan Wrote: Based on your error logs, it seems sqlsrv_connect() is not defined. This means that gou do not have the sqlsrv php extension installed.how can install? |