0

使用此代码,我收到一条错误消息,指出“SelectCommand”不是 StudentTableAdapter 的成员。

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)

连接对象是这个:

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

你能告诉我如何使 SelectCommand 成为表适配器的成员吗?

4

1 回答 1

2

将表适配器的属性“GenerateDirectDBMethods”更改为 True。现在将自动生成更新、删除等命令。

于 2012-10-30T18:42:51.923 回答