vb.nettableadapterselectcommand

Error - 'SelectCommand' is not a member of the table adapter


Using this code I get an error that states 'SelectCommand' is not a member of StudentsTableAdapter.

Dim cmd As New SqlCommand("SELECT * FROM Students WHERE ID=@ID", myConnection)
cmd.Parameters.AddWithValue("@ID", 5)
Me.StudentsTableAdapter.SelectCommand = cmd
Me.StudentsTableAdapter.Fill(Me.StudentsDataSet.Students)

The connection object is this one:

Dim ObjConnection As New SqlConnection(My.Settings.SelimiyeMasjidConnectionString)

Can you tell me how to make the SelectCommand a member of the table adapter?


Solution

  • Change the property "GenerateDirectDBMethods" to True for the Table Adapter. Update, Delete etc commands will be generated automatically now.