Moodle and MS SQL Driving me Insane

Moodle and MS SQL Driving me Insane

by Greg J Preece -
Number of replies: 3
I'm currently trying to set up Moodle on various databases, so that I can work on porting an app of mine across DBs. MySQL and PostgreSQL installed perfectly, and work fine. Good old open source. I've ordered a book for Oracle, it's that mental. But let's talk MS SQL.

My dev boxes are running on Windows XP Pro, and the environment I'm initially using is Apache 2/PHP 5.2. MS SQL Server version is 2005 Express. On SQL Server, I've created a Moodle database for each of Moodle 1.7, 1.8 and 1.9, created a "moodle" user to own them, enabled TCP/IP connections and mixed authentication mode. In PHP, I've uncommented the

extension=php_mssql.dll

line in php.ini, and replaced the ntwdblib.dll file in my \PHP folder with the old version that actually works. With a standard PHP script, a-la:

<?php

echo("Testing MS SQL connection...");

$conn = mssql_connect('HELLDELL\MSSQL2005EXPRESS', 'moodle', '<pass>')
or die(mssql_get_last_message());

mssql_select_db('moodle_1_8', $conn)
or die(mssql_get_last_message());

mssql_close($conn);

echo("Test complete");

?>

This all works fine, and PHP connects to MS SQL. Happy days.

Of course, Moodle can't use the standard MS SQL extension for PHP. You get errors when trying to set up the DB. So I found the instructions over at http://docs.moodle.org/en/Installing_MSSQL_for_PHP. These tell me to use FreeTDS or ODBTP instead. Every other person this has been suggested to has come back with "yep, working now, thanks." Not me...

I followed the instructions for both alternatives to the letter, downloading files, moving DLLs around, installing services and generally mucking about. However, with

extension=php_mssql.dll

uncommented, Moodle tries to use the standard library, and I get the "A problem occurred inserting current version into databases" error, as could be expected. But, the minute I uncomment that line, I get the other error:
Error: Database connection failed.

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been correctly specified in config.php"

My little test script also stops working. This happens whether I'm using FreeTDS or ODBTP and is, quite frankly, doing my nut in. Can anyone tell me where I'm going wrong here? Is there something I'm likely to have missed?

Thanks in advance.

My current freetds.conf:

[global]
host = 192.168.0.26
port = 1433
client charset = UTF-8
tds version = 7.0
text size = 20971520

My current odbtp.conf:

[global]
odbtp host = "HELLDELL"
type = mssql
unicode sql = yes
use row cache = yes
right trim text = yes
var data size = 20971520

(I've tried 192.168.0.26, HELLDELL, and HELLDELL\MSSQL2005EXPRESS in each of the host parameters. I have also remembered to restart everything each time. I just CANNOT get this to work.)
Average of ratings: -
In reply to Greg J Preece

Re: Moodle and MS SQL Driving me Insane

by Richard Enison -
In reply to Richard Enison

Re: Moodle and MS SQL Driving me Insane

by Greg J Preece -
Thanks for your help. I did actually find the problem eventually. It didn't turn up on my searches through the forums, but this thread provided the answer:

http://moodle.org/mod/forum/discuss.php?d=61646

There's a different version of the FreeTDS DLL for each version of PHP, and I was running the one for 5.1. I downloaded the one for 5.2 and Moodle is merrily installing itself as I type this.

I'm off to edit the documentation so others will know in future.

Cheers!