title: Incorrect Syntax near 'WHERE'
body: <p>I am updating my DB through Datagridview. Here is my Update_Button code:</p>
  
  <pre><code> public void SaveDataSet(DataTable table)
  {
  
    foreach (DataRow row in table.Rows)
    {
  
      SqlCommand cmd2 = new SqlCommand(
        @"update dbo.JobStatus 
          SET ShipTransmitStatus = @TransmitStatus, 
            ShipTrackingNumber = @TrackingNum, 
            Carrier = @Carrier, 
            ShipmentProcessedBy = @ProcessedBy, 
            ShipMethodTransmitted = @MethodTransmitted,
          WHERE JobTableId = @JobID ", _mySqlConnec);
  
      //Updated the parameters to the SQL Query!
      cmd2.Parameters.Add(new SqlParameter("@TransmitStatus", row["Status"].ToString()));
      cmd2.Parameters.Add(new SqlParameter("@TrackingNum", row["Tracking#"].ToString()));
      cmd2.Parameters.Add(new SqlParameter("@Carrier", row["Carrier"]));
      cmd2.Parameters.Add(new SqlParameter("@ProcessedBy", row["ProcessedBy"].ToString()));
      cmd2.Parameters.Add(new SqlParameter("@MethodTransmitted", row["MethodTransmitted"].ToString()));
      cmd2.Parameters.Add(new SqlParameter("@JobID", row["JobID"].ToString()));
  
      cmd2.Connection = _mySqlConnec;
      _mySqlConnec.Open();
      cmd2.ExecuteNonQuery();
      _mySqlConnec.Close();
    }
  
  
  }
  </code></pre>
  
  <p>And this is my SELECT statement:</p>
  
  <pre><code>SELECT dbo.InvoiceLineDetail.JobNumber as Job#,dbo.InvoiceLineDetail.PatientName,
         dbo.InvoiceLineDetail.CustomerAccountName as Name, COALESCE(InvoiceLineDetail.ShipAddressAddr2 + ' ','') + COALESCE(InvoiceLineDetail.ShipAddressAddr3+' ','') as Address,
         dbo.InvoiceLineDetail.ShipAddressCity as City, dbo.InvoiceLineDetail.ShipAddressState as State,
         dbo.InvoiceLineDetail.ShipAddressPostalCode as ZipCode, dbo.InvoiceLineDetail.ShipAddressCountry as Country , dbo.JobStatus.ShipTransmitStatus as Status, dbo.JobStatus.ShipTrackingNumber as Tracking#, dbo.JobStatus.Carrier, dbo.JobStatus.ShipMethodTransmitted as MethodTransmitted,
         dbo.JobStatus.DateShipTransmitProcessed as DateProcessed, dbo.JobStatus.ShipmentProcessedBy as ProcessedBy, dbo.JobStatus.Critical,  dbo.JobStatus.JobTableId as JobID, dbo.JobStatus.InvoiceStatus,
         dbo.InvoiceLineDetail.Quantity, dbo.InvoiceLineDetail.ChargeGroup
         FROM dbo.InvoiceLineDetail INNER JOIN
         dbo.View_JobsToShipCount ON dbo.InvoiceLineDetail.CustomerAccountName = dbo.View_JobsToShipCount.CompanyName INNER JOIN
         dbo.JobStatus ON dbo.InvoiceLineDetail.JobID = dbo.JobStatus.JobTableId
         WHERE (dbo.InvoiceLineDetail.ChargeGroup = N'Lens')
  </code></pre>
  
  <p>I am getting an error: Incorrect Syntax near 'WHERE'. Could find out the problem :(</p>