2

Well, I had built an application intended for MSSQL, and originally ran it that way, I bought a new computer and for some odd reason it won't let me connect via MSSQL.

So I set up ODBC. It connects fine, but it seems to hate active records. Am I going to have to rewrite all my queries? or is there something I'm missing. I get errors like this.

A Database Error Occurred
Error Number: 37000
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near ')'.
SELECT * FROM (News) ORDER BY id desc`
Zen
  • 7,197
  • 8
  • 35
  • 57
  • If this worked on your old computer and only broke when you put it onto your new computer, it seems to me the issue would lie with configuration and not the application itself. – Matt Asbury Feb 02 '11 at 13:31

3 Answers3

5

The easy way out is to open the file system/database/drivers/odbc/odbc_driver.php under your CodeIgniter folder. Look for the function named _from_tables (in my case this is line 482).

Change the return statement from:

return '('.implode(', ', $tables).')';

To:

return implode(', ', $tables);

This should do it!

M. Ahmad Zafar
  • 4,881
  • 4
  • 32
  • 44
1

You can change odbc_driver.php file at this location system\database\drivers\odbc and change

return '('.implode(', ', $tables).')' to return implode(', ', $tables); 

in _from_tables() function. This will not add ( and ) in table names and will work perfectly.

Adi Lester
  • 24,731
  • 12
  • 95
  • 110
Yogesh
  • 11
  • 1
0

You could remove ( and ) around the table name. It does not work in SQL Server 2008, too!

ABI
  • 1,714
  • 15
  • 14