SQL SELECT Incorrect syntax near the keyword

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I’m trying to fill a dataview with a sql select statement that works correctly when executed in SSMS but when I put it in my form I get an error.
"Incorrect syntax near the keyword LEFT."
I tried putting LEFT in [] still get the same error.
<pre class="prettyprint DataTable dt = new DataTable();
string conString = callCenterTableAdapter.Connection.ConnectionString;
SqlConnection connection = new SqlConnection(conString);

try
{
connection.Open();
string sqlStatment = @"SELECT CallCenter.ID, [Customer_Data].Name,CallCenter.Request, CallCenter.Statius,CallCenter.Time_Called" +
"FROM CallCenter LEFT JOIN [Customer_Data] ON CallCenter.ID = [Customer_Data].ID " +
"UNION SELECT CallCenter.ID, ProspectiveCustomer.Name, CallCenter.Request, CallCenter.Statius, CallCenter.Time_Called" +
"FROM CallCenter LEFT JOIN ProspectiveCustomer ON CallCenter.ID = ProspectiveCustomer.ID";
SqlCommand sqlCmd = new SqlCommand(sqlStatment, connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
DisplayView = dt.DefaultView;
}
}
[/code]
<br/><hr class="sig why767

View the full article
 
Back
Top