text: Q:
  
  Syntax error near the "INNER" keyword
  
  I am building a Windows form app using a SQL server. The problem I am having is that I am getting an unhandled exception error when I call the .Fill function. Under additional info, it says that there is a syntax error near the INNER keyword. I have written the following code thus far:
  Imports System.Data
  Imports System.Data.SqlClient
  Public Class Form1
      Dim cn As New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename='C:\Users\Sean\Documents\Visual Studio 2013\Projects\Baseball\Baseball\Baseball.mdf';Integrated Security=True")
      Dim da As New SqlDataAdapter
      Dim ds As New DataSet
  
      Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
          Dim sql As String
  
          sql = "SELECT teammates.PlayerName, teammates.Number, teammates.BirthDate, Position.Position, teammates.Salary"
          sql += "From teammates INNER JOIN Position ON teammates.PositionID = Position.PositionID"
  
          With da
              .SelectCommand = New SqlCommand
              .SelectCommand.Connection = cn
              .SelectCommand.CommandText = sql
              .SelectCommand.CommandType = CommandType.Text
  
              cn.Open()
              .Fill(ds, "teammates")
              cn.Close()
          End With
  
          With grdPlayers
              .AutoGenerateColumns = True
              .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells
              .DataSource = ds
              .DataMember = "teammates"
  
          End With
  
          Call FormatGrid()
  
          cn = Nothing
          da = Nothing
  
      End Sub
  
      Private Sub FormatGrid()
          Dim rightStyle As New DataGridViewCellStyle
          rightStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  
          Dim altStyles As New DataGridViewCellStyle
          altStyles.BackColor = Color.WhiteSmoke
          grdPlayers.AlternatingRowsDefaultCellStyle = altStyles
  
          Dim curStyle As New DataGridViewCellStyle
          curStyle.Format = "c"
          curStyle.Alignment = DataGridViewContentAlignment.MiddleRight
  
          With grdPlayers
              .Columns(0).HeaderText = "Name"
              .Columns(1).HeaderText = "Number"
              .Columns(2).HeaderText = "Born"
              .Columns(4).HeaderText = "Position"
              With .Columns(4)
                  .HeaderCell.Value = "Salary"
                  .HeaderCell.Style = rightStyle
                  .DefaultCellStyle = curStyle
              End With
              .Columns(0).HeaderText = "Name"
          End With
      End Sub
  
  End Class
  
  A:
  
  You need a space between the last selected column and FROM. Right now, you query ends up as:
  SELECT ..., teammates.SalaryFROM
  
  Notice the lack of a space. So just add a space to the start of the next string:
  sql += " From teammates INNER
  '       ^ notice the space
  
  Which will result in:
  SELECT ..., teammates.Salary FROM
  --                          ^^ space
  
  