Jul-18-2018, 12:41 PM
obviously your SELECT statement does not return anything. And thus
try
cursor.fetchone()
returns None. As a result your previous code was raising an exception. Now it just continue.try
def checktable(): problemid = PROBIDENTRY.get() connstring = 'DRIVER={SQL Server};SERVER=OBDEVSQLAGL05;DATABASE=DCollection;UID=xxxx;PWD=yyyy' SQLstr="select OWNER from GD_SERV_ADMIN where PROBLEMID=?" conn=pyodbc.connect(connstring) cursor=conn.cursor() cursor.execute(SQLstr, problemid ) row = cursor.fetchone() if row: messagebox.showinfo("Owner found", "The ADMIN for this problem ID is: " + row[0]) cursor.close() PROBIDENTRY.delete(0,END)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs