Spaces.
string query = "SELECT DISTINCT indent_no as 'Indent No' ," +
"approved_date as 'Approved Date'," +
"from_store_name as 'From Store',to_store_name as 'To Store'," +
"indent_status as 'Indent Status'," +
"processing_status as 'Processing Status'" +
"FROM vw_DSInfo_indent_details" +
"WHERE [indent_status] like '"+ap+"'" +
Generates a string like:
SELECT DISTINCT ...processing_status as 'Processing Status'FROM vw_DSInfo_indent_detailsWHERE [indent_status] like ...
You get away with it for the
Status'FROM
becuaset the quote terminates the prvious data. But
vw_DSInfo_indent_detailsWHERE
is taken as a single word.
And please, don't do it like that.
Do not 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. Use Parametrized queries instead. You get away with it here because you define the strings yourself, but it's a dangerous precedent and may well leave you wide open to SQL Injection if the code is ever changed. Get into the habit of using parameterised queries at all times - it's a lot easier to read, and a lot safer!