I'm getting a syntax error from my SQL command shown in the code below. The error is happening on the ExecuteReader
line, saying
Incorrect syntax near the keyword 'JOIN'.'
I have no idea why it's throwing a syntax error, the command works perfectly fine in SQL Server. Here's the code:
private void button1_Click(object sender, EventArgs e)
{
SqlCommand sqlcomViewSmashRoster;
SqlDataReader dataReader;
String strSql, strOutput ="";
strSql = "SELECT Roster.CharacterName, Roster.TotalTournamentsParticiaped, Roster.TotalWins, Roster.TotalLosses, Roster.Championships, Roster.InjuriesCaused, Roster.Injured" +
"FROM Roster" +
"INNER JOIN VideoGames" +
"ON VideoGames.VideoGame_ID = Roster.VideoGame_ID" +
"WHERE roster.VideoGame_ID = 2";
cnn.Open();
sqlcomViewSmashRoster = new SqlCommand(strSql, cnn);
dataReader = sqlcomViewSmashRoster.ExecuteReader();
while (dataReader.Read())
{
strOutput = strOutput + dataReader.GetValue(0) + " - " + dataReader.GetValue(1) + "\n";
}
cnn.Close();
MessageBox.Show(strOutput);
}
Thanks!