Incorrect Syntax Near The Keyword 'Order' - Order Is Table Name
List results = new List(); db.Cmd = db.Conn.CreateCommand(); db.Cmd.CommandText = 'SELECT * FROM Order'; db.Rdr = db.Cmd.ExecuteReader(); while (db.Rdr.
Solution 1:
You will need to put the name of the table in square brackets in order for it to work.
List<Order> results = new List<Order>();
db.Cmd = db.Conn.CreateCommand();
db.Cmd.CommandText = "SELECT * FROM [Order]";
db.Rdr = db.Cmd.ExecuteReader();
while (db.Rdr.Read())
{
results.Add(getOrderFromReader(db.Rdr));
}
db.Rdr.Close();
return results;
Order is a SQL reserved word, so you might think about renaming that table, if you can.
Solution 2:
Order is a keyword in SQL used for Ordering/sorting of the resultset.
Here the complier is getting confused with the keyword and your table name.
Solutions :
Rename your table name
Enclose your table name in brackets. [Order]. ie, Select * From [Order]
Post a Comment for "Incorrect Syntax Near The Keyword 'Order' - Order Is Table Name"