Reputation: 11730
I can't seem to figure out why this statement is giving me problems:
sqlCommand.CommandText = @"INSERT INTO Fulfilled_Shipments_Data (amazon-order-id) VALUES " + lines[0];
I am getting error:
[Error]: There was an error parsing the query. [ Token line number = 1,Token line offset = 44,Token in error = - ]
which points to the - in amazon-order-id.
I get the same error when I execute the SQL from within visual studio, however I can query existing data using that column name.
I am sure this is a trivial matter for a SQL guru, but I am scratching my head so any assistance is appreciated!
Upvotes: 0
Views: 7496
Reputation: 11
try these .
sqlCommand.CommandText = @"INSERT INTO Fulfilled_Shipments_Data (amazon-order-id) VALUES ('" + lines[0]+"')";
OR
sqlCommand.CommandText = @"INSERT INTO Fulfilled_Shipments_Data ([amazon-order-id]) VALUES ('" + lines[0]+"')";
Upvotes: 1
Reputation: 37354
You need to escape amazon-order-id
because it has minus(dash) sign. It should be [amazon-order-id]
:
...INSERT INTO Fulfilled_Shipments_Data ([amazon-order-id])...
Also, values should be in parenthesis :VALUES (" + lines[0]+")";
Final version:
sqlCommand.CommandText = @"INSERT INTO
Fulfilled_Shipments_Data ([amazon-order-id])
VALUES (" + lines[0]+")";
Upvotes: 5
Reputation: 7761
I think your SQL syntax should look like this:
sqlCommand.CommandText = @"INSERT INTO Fulfilled_Shipments_Data (amazon-order-id) VALUES ('" + lines[0] + "')";
OR
sqlCommand.CommandText = @"INSERT INTO Fulfilled_Shipments_Data (amazon-order-id) VALUES (" + lines[0] + ")";
depending on the data type of amazon-order-id
Upvotes: 2