I\'m hoping to use the following update\\insert method to speed up my application insert\\updates:
UPDATE [Application_Type_Table]
SET ApplicationType=\'Test Va
sqlCommand.CommandText = "IF NOT EXISTS (SELECT 1 FROM [Application_Type_Table] WHERE "_
"ID='1') BEGIN INSERT INTO " _
"[Application_Type_Table] VALUES ('Test Value') END ELSE BEGIN UPDATE [Application_Type_Table]"_
"SET ApplicationType='Test Value'"_
"WHERE ID='1' END"
I would suggest moving the query to a stored procedure. Queries (especially multi-statement ones) don't really belong hard-coded into one's application IMO. Doing so would also have the bonus of alleviating your problem ;)
This pattern is known as an UPSERT. The modern way of doing this is to use MERGE in SQL Server 2008 e.g.
MERGE INTO Application_Type_Table AS target
USING (
VALUES (@RecordID, @TestValue)
) AS source (ID, ApplicationType)
ON target.ID = source.ID
WHEN MATCHED
THEN UPDATE
SET ApplicationType = source.ApplicationType
WHEN NOT MATCHED
THEN INSERT (ID, ApplicationType)
VALUES (ID, ApplicationType);