Je suis en train de mettre à jour ma base de données via Datagridview. Voici mon code Update_Button:Syntaxe incorrecte près de 'WHERE'
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();
}
}
Et voici mon instruction SELECT:
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')
Je reçois une erreur: Syntaxe incorrecte près 'WHERE'. Pourrait trouver le problème :(