Hi We had this same error message recently - it was because the permissions to the database had not been set/reset correctly after an upgrade, worked fine again after permissions were amended regards Karen
In my case, it was because the permissions on the data directory "moodledata" were too tight.
In Moodle 1.9 "moodledata" is moved out of the web accessible directory by default. Try temporarily setting permissions to "all" (for Linux "0777"). It can happen if you (like us) moved the old moodledata using ftp on a provider site.