user3151557
user3151557

Reputation: 31

Error in SQL syntax statement when updating database

C# keeps coming up with an error:

Additional information: You have an error in your SQL syntax

My SQL statement is at the bottom in the picture.

enter image description here

Sql statement:

Update amazon_ordred_items
Set OrderItemId = 666854391288218,
    SellerSKu = ..,
    Title = 2pcs Fashion Cool Universal Black Real Original Car Headlight Eyelashes Sticker,
    QuantityOrdered = 1,
    QuantityShipped = 1,
    CurrencyCode = USD,
    Amount = 0.50,
    ScheduledDeliveryEndDate = ..,
    ScheduledDeliveryStartDate = ..,
    PromotionIds = .,
Where ASIN = B00EISTU74

Upvotes: 0

Views: 59

Answers (2)

Dmitriy Khaykin
Dmitriy Khaykin

Reputation: 5258

The problem is you are not using single quotes for any of your string values in the update statement. Put quotes on every value that is not an integer and the sql statement will work.

Also you have values of .. for some date fields. Assuming those are of an SQL data type DateTime or similar, this will not work. If you don't have a date, use Null instead.

Update amazon_ordred_items
Set OrderItemId = 666854391288218,
    SellerSKu = Null,
    Title = '2pcs Fashion Cool Universal Black Real Original Car Headlight Eyelashes Sticker',
    QuantityOrdered = 1,
    QuantityShipped = 1,
    CurrencyCode = 'USD',
    Amount = 0.50,
    ScheduledDeliveryEndDate = Null,
    ScheduledDeliveryStartDate = Null,
    PromotionIds = Null,
Where ASIN = 'B00EISTU74'

Note also there's no need to update the ASIN field since you're not changing it's value and it is in your Where clause.

Upvotes: 0

wallyk
wallyk

Reputation: 57764

One thing which would make this a lot better is to add quotes around the text strings in the query:

update table
set  sellerSK='.',
     Title='2pcs Fashion...',
     (etc)

Can't tell from the screenshot if this is the problem, but it certainly looks like it is an issue.

Upvotes: 1

Related Questions