2011-08-22 103 views
0

數據我想基於以下字段搜索記錄搜索從數據集中

P_num ,P_name, P_dob,P_code 

我使用4代以上的表以檢索數據, 我已經創建的數據集名爲P_search,我想數據填充到數據集和根據哪個字段被選擇用於搜索目的來顯示它。

我建議通過創建自己的功能,其中所有字段和布爾變量將被視爲參數

請幫我用VB.net編寫代碼編寫代碼。

我對VB.net很新。其他任何人都可以幫助我提供上述代碼。

預先感謝您

+0

我真的不趟:您可以請編輯您的問題給你的意思的例子嗎?如果您可以展示一些示例表格,並向我們展示您想要調用的內容以及您希望它返回的內容,那麼向您展示如何做到您想要的內容會更容易。 – shelleybutterfly

+0

我想寫的功能,我可以根據上面提到的字段retirve記錄並顯示它。例如,如果按照P_num搜索記錄,則提供Pnum而不是屬於該p_num應顯示的數據。 – comkalp

回答

1

您使用DataTable.Select Method

Private Sub GetRowsByFilter() 

    Dim table As DataTable = DataSet1.Tables("Orders") 

    ' Presuming the DataTable has a column named Date. 
    Dim expression As String 
    expression = "Date > #1/1/00#" 
    Dim foundRows() As DataRow 

    ' Use the Select method to find all rows matching the filter. 
    foundRows = table.Select(expression) 

    Dim i As Integer 
    ' Print column 0 of each returned row. 
    For i = 0 to foundRows.GetUpperBound(0) 
     Console.WriteLine(foundRows(i)(0)) 
    Next i 
End Sub 
+0

我想要控制檯應用程序。我正在設計網站 – comkalp

+0

控制檯應用程序僅用於理解示例,您可以對網站執行相同的操作。 –