Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Gateway Error 301: SQL error for “INSERT INTO Customers2 (ID) VALUES (NULL)”: Cannot insert the value NULL into column ‘ID’, table ‘WEDatabase.dbo.Customers2’; column does not allow nulls. INSERT fails.
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column ‘ID’, table ‘WEDatabase.dbo.Customers2’; column does not allow nulls. INSERT fails.
I do not. Not really sure how to do that. I am new to this stuff.
I just looked at the properties of the ID column in Microsoft SQL server Management Studio 2008 and I see Identity Increment and it is set to 0 but all of the properties are all greyed out so I can’t change anything.
Your error is telling you that table cannot take NULL values for the ID column."INSERT INTO Customers2 (ID) VALUES (NULL)": Cannot insert the value NULL into column 'ID', table 'WEDatabase.dbo.Customers2'; column does not allow nulls. INSERT fails.You need to set the ID column to auto-increment if you want to insert a NULL
Each database is different, but in SQLServer Management Studio: Right-click on the table, ‘Design’ it, and click on the id column. In the properties, set the identity to be seeded @ e.g. 1 and to have increment of 1 - save and you’re done.
In MySQL Workbench: Right-click on the table, ‘Alter Table…’, and click on the columns tab. In the row for ID, set the PK and AI check boxes - apply and you’re done.
That table definition looks perfect. By using an insert statement like INSERT INTO Customers2 (ID) VALUES (NULL)you are telling SQLServer to ignore your auto-increment and instead insert a NULL value into the ID column. Now try something like INSERT INTO Customers2 (name) VALUES ("Joe")
For those of you following along at home, we got this problem ironed out over the phone. The problem was a Python syntax issue, and the correct code was:query = "INSERT INTO customers2 (name, address, phone) VALUES ('name', 'address', 'phone')"
system.db.runUpdateQuery(query)