0

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?

Emad-ud-deen
  • 4,734
  • 21
  • 87
  • 152
  • I found out that since I used the wizards to create this table adapter the select command is private. After further investigation I found that it's stored in the dataset designer as a query. I created a new query but I don't know how to select that query in my code that has the .Fill method. Can you tell me how to load parameters into the new query and use it in the .Fill method call? – Emad-ud-deen Mar 01 '12 at 14:06

1 Answers1

2

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

Raj
  • 22,346
  • 14
  • 99
  • 142
  • what if this won't even allow to set GenerateDirectDBMethods to true due to joins and where conditions, if the basic query is from multiple table – Meetu Choudhary Dec 28 '12 at 08:43