Incorrect syntax near '(' and near '='
<p>What I'm trying to do is to update an entry, and if it doesn't exist - create a new one.</p>

<p><a href="https://blogs.msdn.microsoft.com/miah/2008/02/17/sql-if-exists-update-else-insert/" rel="nofollow">This</a> is what I'm trying to follow.</p>

<p>I'm getting a syntax error exception, and I have no idea what's wrong.</p>

<hr>

<p>That's how I make my table:</p>

<pre><code>CREATE TABLE [dbo].[Rides] (
    [phone]       VARCHAR (32)  NOT NULL,
    [destination] VARCHAR (50)  NOT NULL,
    [departure]   VARCHAR (50)  NOT NULL,
    [time]        DATETIME      NOT NULL,
    [comment]     NVARCHAR (50) NOT NULL,
    PRIMARY KEY CLUSTERED ([phone] ASC)
);
</code></pre>

<p>That's my query:</p>

<pre><code>SqlCommand command = connection.CreateCommand();
command.CommandText =
@"UPDATE Rides SET (destination=@Dest, departure=@Depart, time=@Time, comment=@Comment) WHERE phone=@UName
IF (@@ROWCOUNT=0)
    INSERT INTO Rides VALUES (destination=@Dest, departure=@Depart, time=@Time, comment=@Comment)";

command.Parameters.AddWithValue("@UName", entry.phone);
command.Parameters.AddWithValue("@Dest", entry.destinationID);
command.Parameters.AddWithValue("@Depart", entry.departureID);
command.Parameters.AddWithValue("@Time", entry.time.ToString("yyyy-MM-dd HH:mm:ss:fff"));
command.Parameters.AddWithValue("@Comment", entry.comment);
command.ExecuteNonQuery();
</code></pre>

<p>That's <code>entry</code>:</p>

<pre><code>public struct Entry
{
    public string phone;
    public string destinationID;
    public string departureID;
    public DateTime time;
    public string comment;
}
</code></pre>

<p>That's my error:</p>

<blockquote>
  <p>An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code</p>
  
  <p>Additional information: Incorrect syntax near '('.</p>
  
  <p>Incorrect syntax near '='.</p>
</blockquote>

<p>Stack trace:</p>

<pre><code>[SqlException (0x80131904): Incorrect syntax near '('.
Incorrect syntax near '='.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2442126
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5736904
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +628
   System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady) +3731
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +225
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2026
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp; task, Boolean asyncWrite) +375
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite) +337
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +280
   RidesDatabaseAccessor.updateEntry(Entry entry) in c:\Users\Climax708\Documents\Programming\TrempLehayal\App_Code\RidesDatabaseAccessor.cs:145
   newride.Page_Load(Object sender, EventArgs e) in c:\Users\Climax708\Documents\Programming\TrempLehayal\newride.aspx.cs:75
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2952
</code></pre>