在OBS02DataSet_12.vb中自行撰寫:
Namespace OBS02DataSet1TableAdapters
Partial Public Class OBS12TableAdapter
Public ReadOnly Property DbCommandCollection() As IDbCommand()
Get
Return Me.CommandCollection
End Get
End Property
Public Function FillWhere(ByVal dataTable As DataTable, ByVal whereExpression As String) As Integer
Dim text1 As String = Me.CommandCollection(0).CommandText
Try
Me.CommandCollection(0).CommandText += " WHERE " + whereExpression
Return Me.Fill(DataTable)
Finally
Me.CommandCollection(0).CommandText = text1
End Try
End Function
End Class
End Namespace
用法:
Dim whereExpression As String = "lastname='batman'" '組WHERE字串
Me.OBS12TableAdapter.FillWhere(Me.OBS02DataSet_12.OBS12, whereExpression)