Try replace DAL('mssql://...') with DAL('mssql2://...')

On Jan 3, 4:45 pm, Roman Bataev <roman.bat...@gmail.com> wrote:
> The following code works fine in 1.79.2 but gives an error in 1.91.6. Any
> ideas?
>
> tntdb = SQLDB(tnt_connection_string) #this connects to MS SQL Server
>
> tntdb.define_table('Employees',
>     Field('employeeID', 'id'),
>     Field('firstName', length=20),
>     Field('networkUsername'),
>     Field('isManager', 'boolean'), #isManager has type BIT in the database
>     migrate=False)
>
> def _find_user_by_name(username):
>     return tntdb((tntdb.Employees.networkUsername == username) &
> (tntdb.Employees.isManager == True)).select()
>
> Calling _find_user_by_name() works fine in 1.79.2 but gives the following
> error in 1.91.6:
>
> Thread-11 2011-01-03 17:34:32,289 ERROR login() Traceback (most recent call
> last):
>   File "c:\web2py\applications\scandabamc/controllers/default.py", line 129,
> in login
>     user = _find_user_by_name(request.vars.username)
>   File "c:\web2py\applications\scandabamc/controllers/default.py", line 164,
> in _find_user_by_name
>     return tntdb((tntdb.Employees.networkUsername == username) &
> (tntdb.Employees.isManager == True)).select()
>   File "c:\web2py\gluon\dal.py", line 4507, in select
>     return self.db._adapter.select(self.query,fields,attributes)
>   File "c:\web2py\gluon\dal.py", line 1003, in select
>     rows = response(sql)
>   File "c:\web2py\gluon\dal.py", line 994, in response
>     self.execute(sql)
>   File "c:\web2py\gluon\dal.py", line 1067, in execute
>     return self.log_execute(*a, **b)
>   File "c:\web2py\gluon\dal.py", line 1064, in log_execute
>     return self.cursor.execute(*a,**b)
> DataError: ('22018', "[22018] [Microsoft][ODBC SQL Server Driver][SQL
> Server]Conversion failed when converting the varchar value 'T' to data type
> bit. (245) (SQLExecDirectW)")

Reply via email to