I have created the below Python Tkinter application to insert values from text entry boxes into a SQL Server table. The program runs and insert number values into the SQL table but fails when trying to use letters and returns an
Exception in Tkinter callback
pyodbc.ProgrammingError: ('42S22', "[42S22] [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'asdf'. (207) (SQLExecDirectW)").
Code for the insert function.
value1=DENSITY_VALUE.get()
value2=DATE_1.get()
value3=TIME_1.get()
value4=CHART_VALUE.get()
# Insert into table
cursor.execute("INSERT INTO TEST_DISA_MAIN_TABLE(DENSITY_VALUE, DATE_1, TIME_1, CHART_VALUE) VALUES ("+value1+", "+value2+", "+value3+", "+value4+")")
# Commit changes
conn.commit()
# Close Connection
conn.close()
# Clear the text boxes
DENSITY_VALUE.delete(0, END)
DATE_1.delete(0, END)
TIME_1.delete(0, END)
CHART_VALUE.delete(0, END)