I have listed two SQL Insert statements use in an ASP page. The first SQL inserts four rows into the database, the second only one, as they both should. The objective is to write a row to the db and obtain the identity field to write to another table as the link field. The question is; Why is the first SQL statement writing four rows to the database?
Thanks in advance!!!
strSQLInsert1 = "SET NOCOUNT ON; INSERT INTO Disposal_Header(UserID, UnitNumber, UnitName, Phone) VALUES ('" & strUserID & "' , '" & strUnitNumber & "', '" & strUnitName & "', '" & strPhone & "') SELECT @@IDENTITY AS RetVal;SET NOCOUNT OFF"
strSQLInsert2 = " INSERT INTO Disposal_Header(UserID, UnitNumber, UnitName, Phone) VALUES ('" & strUserID & "' , '" & strUnitNumber & "', '" & strUnitName & "', '" & strPhone & "')"
Thanks in advance!!!
strSQLInsert1 = "SET NOCOUNT ON; INSERT INTO Disposal_Header(UserID, UnitNumber, UnitName, Phone) VALUES ('" & strUserID & "' , '" & strUnitNumber & "', '" & strUnitName & "', '" & strPhone & "') SELECT @@IDENTITY AS RetVal;SET NOCOUNT OFF"
strSQLInsert2 = " INSERT INTO Disposal_Header(UserID, UnitNumber, UnitName, Phone) VALUES ('" & strUserID & "' , '" & strUnitNumber & "', '" & strUnitName & "', '" & strPhone & "')"