我不断收到此 pyodbc 驱动程序错误,我根本无法修复它,谁能帮忙?我正在使用具有 microsoft 访问权限的 pyqt4 作为数据存储库。忽略任何狡猾的缩进。
这是我的错误:
Traceback (most recent call last):
File "F:\computing\Payroll v2 2\mainwindow.py", line 53, in loadUpcomingBirthdaysForm
self.ui.upcomingBirthdaysForm = UpcomingBirthdays.UpcomingBirthdays()
File "F:\computing\Payroll v2 2\UpcomingBirthdays.py", line 22, in __init__
cursor.execute("select Forename,Surname,DOB from employees where (DOB=?))",9)
pyodbc.Error: ('HYC00', '[HYC00] [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented (106) (SQLBindParameter)')
这是我的代码:
from PyQt4 import uic
from PyQt4 import QtCore,QtGui
import validation
import pyodbc
import datetime
( Ui_UpcomingBirthdays, QMainWindow ) = uic.loadUiType( 'UpcomingBirthdays.ui' )
class UpcomingBirthdays ( QMainWindow ):
"""Upcoming Birthdays inherits QMainWindow"""
def __init__ ( self, parent = None ):
QMainWindow.__init__( self, parent )
self.ui = Ui_UpcomingBirthdays()
self.ui.setupUi( self )
today = datetime.date.today()
thismonth= int(today.strftime("%m")[0:2])
thisday= int(today.strftime("%d")[0:2])
cnxn = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Dbq=F:\\computing\\Payroll v2 2\\employees.accdb')
cursor = cnxn.cursor()
cursor.execute("select Forename,Surname,DOB from employees where (DOBmonth=?))",thismonth)
residentList = cursor.fetchall()
cnxn.close()
self.ui.residentTableWidget.setRowCount(0)
for item in residentList:
print (item)
rowcount = self.ui.residentTableWidget.rowCount()
self.ui.residentTableWidget.insertRow(rowcount)
self.ui.residentTableWidget.setItem(rowcount,0,QtGui.QTableWidgetItem(str(item[0])))
self.ui.residentTableWidget.setItem(rowcount,1,QtGui.QTableWidgetItem(str(item[1])))
self.ui.residentTableWidget.setItem(rowcount,2,QtGui.QTableWidgetItem(str(item[2])))
def __del__ ( self ):
self.ui = None