Hello
I am new to SQL programming.
My question is when populating a new row in a database, I have found that you must first INSERT INTO PrimaryKey(s) first and then you can UPDATE the other Fields. I have found you must do this in 2 steps. Is this true?
Code:
'this works
SQL = "INSERT INTO myTable (thePrimaryKeyField) VALUES (value1)"
Call UpdateDatabaseData(SQL)
SQL = "UPDATE myTable SET theNonPrimaryKeyField = value2"
Call UpdateDatabaseData(SQL)
'this generates an error
SQL = "INSERT INTO myTable (thePrimaryKeyField, theNonPrimaryKeyField) VALUES (value1,value2)"
Call UpdateDatabaseData(SQL)
I was hoping you could create a new row by populating the PrimaryKey and other Fields at the same time within the same SQL statement?
When I try to do it at the same time I get an error so unless there is some other error in my code that I cannot find, this is the only reason I can think of.
Thank you.