Don't do it like that! Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead.
When you concatenate strings, you cause problems because SQL receives commands like:
SELECT * FROM MyTable WHERE StreetAddress = 'Baker's Wood'
The quote the user added terminates the string as far as SQL is concerned and you get problems. But it could be worse. If I come along and type this instead: "x';DROP TABLE MyTable;--" Then SQL receives a very different command:
SELECT * FROM MyTable WHERE StreetAddress = 'x';DROP TABLE MyTable;
Which SQL sees as three separate commands:
SELECT * FROM MyTable WHERE StreetAddress = 'x';
A perfectly valid SELECT
DROP TABLE MyTable;
A perfectly valid "delete the table" command
And everything else is a comment.
So it does: selects any matching rows, deletes the table from the DB, and ignores anything else.
So ALWAYS use parameterized queries! Or be prepared to restore your DB from backup frequently. You do take backups regularly, don't you?
In this specific case it won't risk your DB getting deleted, - it'll do something much worse. It risks your data being inaccurate, or mixed inaccurate with accurate, or failing at the end of the month, etc.
You are specifying a string based format European date - and that's fine (ish) until the database system is changed, upgraded, or reconfigured. If the date locale in use doesn't match European date format, then you will start to get real problems - and a new PC / new SQL Server installation will default to US dates, and your problems start ...
Just use parameters, and pass the actual value instead of a text string and all of this goes away.
And look at your code:
string query = "select o.OrderID, c.CustomerID, c.ContactName, c.Address, c.PostalCode, c.City, c.Phone, o.OrderDate" +
"from Orders o inner join Customers c on o.CustomerID = c.CustomerID" +
Lets cut out the dross, so you can see where the problem is:
string query = "... , o.OrderDate" +
"from Orders o ..." +
Join 'em together and the string passed to SQL is:
"... , o.OrderDatefrom Orders o ..."
You need a space in there.