'This write only attribute identifies which table will be searched
Public WriteOnly Property TableName as string
Set
'设置表的名称
strTableName = Value
End Set
End Property
'这个程序依照属性的值来操纵一个数据库
Public Sub Search(sender As Object , e As System.EventArgs)
Dim cnConnection As SQLConnection
Dim cmdCommand As SQLDataSetCommand
Dim strSearchString As String
Dim strSQL As String
'如果用户在搜索框中输入了条件
If txtSearch.Text <> "" Then
'过滤掉字符的前后空格
strSearchString = trim$(txtSearch.Text)
End If
'建立我们的SQL语句
strSQL = "SELECT * " & _
"FROM " & strTableName & _
" WHERE " & strConditionField & " LIKE '" & _
trSearchString & "%'"
'如果联接属性被设置了
If strConnection <> "" Then
'建立数据库联接
cnConnection = New SQLConnection(strConnection)
'打开数据库联接
cnConnection.open()
'为搜索建立一个新的command对象
cmdCommand = New SQLDataSetCommand(strSQL, cnConnection)
'建立一个新的DataSet对象
dsData = New DataSet()
'填充dataset对象
cmdCommand.FillDataSet(dsData, "BookTitles")
End If
End Sub