--过程
Namespace DataSet1TableAdapters
Partial Class ZHSH_MV_SHOPTableAdapter
Inherits System.ComponentModel.Component
Public Property SelectCommand() As OracleClient.OracleCommand()
Get
If (Me._commandCollection Is Nothing) Then
Me.InitCommandCollection()
End If
Return Me._commandCollection
End Get
Set(ByVal value As OracleClient.OracleCommand())
Me._commandCollection = value
End Set
End Property
Public Function FillByWhere(ByVal dataTable As DataSet1.ZHSH_MV_SHOPDataTable, ByVal WhereExp As String) As Integer
Dim stSelect As String
stSelect = Me._commandCollection(0).CommandText
Try
Me._commandCollection(0).CommandText += " WHERE " + WhereExp
Return Me.Fill(dataTable)
Catch ex As Exception
Finally
Me._commandCollection(0).CommandText = stSelect
End Try
End Function
End Class
End Namespace
--按钮
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim stCustID As String = Trim(TextBox1.Text)
Dim stShipCntry As String = Trim(TextBox2.Text)
' Pass in a SELECT with no WHERE that conforms to the the DataTAble
' used by the TableAdapter's DataSet
Me.ZHSH_MV_SHOPTableAdapter.SelectCommand(0).CommandText = _
"SELECT * FROM oracle.ZHSH_MV_SHOP"
' Build a string containing WHERE criteria (without the WHERE)
Dim stWhere As String = ""
If stCustID <> "" Then
stWhere = "shopid LIKE '" + stCustID + "%' AND "
End If
If stShipCntry <> "" Then
stWhere += "shopname LIKE '" + stShipCntry + "%' "
Else
stWhere = Replace(stWhere, " AND ", "")
End If
If stWhere = "" Then
Me.ZHSH_MV_SHOPTableAdapter.Fill(Me.DataSet1.ZHSH_MV_SHOP)
Else
Me.ZHSH_MV_SHOPTableAdapter.FillByWhere(Me.DataSet1.ZHSH_MV_SHOP, stWhere)
End If
End Sub
[ 此帖被memoriesoff在2011-01-19 09:15重新编辑 ]