title: How do you delete a value from a Database through a dropdownlist?
body: <p>Basically I'm trying to give the function to the user to delete data relating to a staff member by selecting their name from the dropdown list and clicking done, but I keep getting error messages such as </p>
  
  <blockquote>
    <p>"Incorrect syntax near "," "</p>
  </blockquote>
  
  <p>but Ive put in checkpoints and can see that no value is being picked up so I was wondering would anyone have idea as to where I am going wrong??</p>
  
  <pre><code> Dim Con As SqlConnection
      Dim cmd As SqlCommand
      Dim recordsAffected As String
      Dim cmdstring As String = "Delete StaffID, FullName, Gender, Age, Driver, StartDate, ContactNumber, Waistcoat WHERE FullName = DropDownList1.SelectedValue"
      Con = New SqlConnection("Data Source=OISINMCGRANN-PC\SQLEXPRESS;Initial Catalog=YellowDoor;Integrated Security=True")
      cmd = New SqlCommand(cmdstring, Con)
      Con.Open()
      RecordsAffected = cmd.ExecuteNonQuery()
      Con.Close()
  End Sub
  </code></pre>
  
  <p>I've tried this without the dropdownlist in quotations:</p>
  
  <pre><code>   Dim Con As SqlConnection
          Dim cmd As SqlCommand
          Dim recordsAffected As String
          Dim cmdstring As String = "Delete StaffID, FullName, Gender, Age, Driver, StartDate, ContactNumber, Waistcoat WHERE FullName =" + DropDownList1.SelectedValue
          Con = New SqlConnection("Data Source=OISINMCGRANN-PC\SQLEXPRESS;Initial Catalog=YellowDoor;Integrated Security=True")
          cmd = New SqlCommand(cmdstring, Con)
          Con.Open()
          RecordsAffected = cmd.ExecuteNonQuery()
          Con.Close()
      End Sub
  </code></pre>