title: Nonetype object has no attribute 'id'
body: <p>I am retrieving the last id from mssql and trying to incrementing it and storing the fie name with the id.. But I am getting "Attribute error : Nonetype object has no attribute 'id'"..The code and the error goes here :</p>
  
  <pre><code>import Tkinter,tkFileDialog 
  import shutil    
  import pyodbc    
  cnxn = pyodbc.connect("DRIVER={SQL Server};SERVER=PAVAN;DATABASE=video;Trusted_Connection=yes;")   
  cursor = cnxn.cursor()  
  cursor.execute("SELECT TOP 1 id  FROM files ORDER BY id DESC ")
  
  while 1:   
      row = cursor.fetchone()  
      if not row:   
          break   
      print row.id    
  cnxn.close()    
  middle = Tkinter.Tk()
  
  def withdraw():    
     dirname = tkFileDialog.askopenfilename(parent=middle,initialdir="H:/",title='Please 
  select a file')    
     a="H:python(test)\py_"+row.id+".mp4"    
     b=shutil.copyfile(dirname,a)
  
     if b!="":    
         print "Successfully Copied"    
     else:    
         print "Could not be copied"
  
  B = Tkinter.Button(middle, text ="UPLOAD", command = withdraw)    
  middle.geometry("450x300+100+100")    
  middle.configure(background="black")    
  B.pack() 
  middle.mainloop() 
  </code></pre>
  
  <p>The error I'm getting is:  </p>
  
  <pre><code>Traceback (most recent call last):  
    File "C:\Python27\lib\lib-tk\Tkinter.py", line 1470, in __call__
        return self.func(*args)
    File "C:\Users\hp\Desktop\upload.py", line 20, in withdraw
      a="H:python(test)\py_"+row.id+".mp4"
  AttributeError: 'NoneType' object has no attribute 'id'
  </code></pre>