Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to find a record in Dataset?

dradra Posts: 3
Hi,

I am using Dataset and Windows Form and want to use relative search using search key. Yes of course i can move the record pointer using absolute position, but i could not get any method or class associated with dataset to find using a search key.

Comments

  • natloznatloz Posts: 54
    [b][red]This message was edited by natloz at 2004-6-11 7:31:57[/red][/b][hr]
    [b][red]This message was edited by natloz at 2004-6-11 7:29:18[/red][/b][hr]
    This is how I search a Dataset...
    [code]
    'Create a dataview
    dim dv as new dataview

    'Associate the dataview to _oDs (Dataset table)
    dv.Table = _oDs.Tables("tblCapitalCategory")

    Dim drv As DataRowView 'Data Row View object to query DataView object

    'Filter based on a combo box value selected
    dv.RowFilter = "[pkCapitalCategoryID] = " & CInt(cboComboBox.SelectedValue)

    'Retrieve my values returned in the result
    For Each drv In dv
    _dteDateModified = drv("dteDateModified")
    Next
    [/code]
    Hopefully you get some use of this. I use this method to search for any values in my datasets.

    [code]
    dv.RowFilter is the key to the search. It is kind of like a SQL where statement on the results of the dataset.
    [/code]
    The nice thing about this method is the original dataset is not manipulated in any way. You do everything based on a manipulated view of the datasets results.

    \--||--//

    //--||--\





  • d2prescod2presco Posts: 16
    I'm fairly new to .NET but this is the way i figured out how to search a dataset pulled from an MS Acess database.

    basically the record text is visible so i brought up an input box and IF the textbox text matched the record text I pulled up a msg box...
    Private Sub btnStockSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStockSearch.Click intTotalRec = BindingContext(DataSet11, "mdbShaun").Count intCurrentRec = 0 Me.BindingContext(DataSet11, "mdbShaun").Position = 0 lblRecNo.Text = intCurrentRec + 1 Dim strStockSearch As String strStockSearch = InputBox("Enter Stock Number EX: U9301 or 2325:", "Search for Stock Number", "Type Here", , ) MsgBox("Searching", MsgBoxStyle.Information, "Searching...") Dim intCounter As Integer = 0 For intCounter = 0 To (intTotalRec - 1) lblRecNo.Text = intCurrentRec + 1 lblTotalRec.Text = intTotalRec 'SNAG when .text boxes = strStockSearch If (txtStatus2.Text = ("" & strStockSearch)) Then MsgBox("FOUND MATCH", MsgBoxStyle.Exclamation, "FOUND MATCH") Else End If intCurrentRec = intCurrentRec + 1 Me.BindingContext(DataSet11, "mdbShaun").Position = tCurrentRec Next MsgBox("Finished Searching.", MsgBoxStyle.Information, "Finished.") intCurrentRec = 0 lblRecNo.Text = intCurrentRec + 1 Me.BindingContext(DataSet11, "mdbShaun").Position = 0 End Sub

    : Hi,
    :
    : I am using Dataset and Windows Form and want to use relative search using search key. Yes of course i can move the record pointer using absolute position, but i could not get any method or class associated with dataset to find using a search key.
    :
    :

  • natloznatloz Posts: 54
    : I'm fairly new to .NET but this is the way i figured out how to search a dataset pulled from an MS Acess database.
    :
    : basically the record text is visible so i brought up an input box and IF the textbox text matched the record text I pulled up a msg box...
    : : Private Sub btnStockSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStockSearch.Click : intTotalRec = BindingContext(DataSet11, "mdbShaun").Count : intCurrentRec = 0 : Me.BindingContext(DataSet11, "mdbShaun").Position = 0 : lblRecNo.Text = intCurrentRec + 1 : Dim strStockSearch As String : : strStockSearch = InputBox("Enter Stock Number EX: U9301 or 2325:", "Search for Stock Number", "Type Here", , ) : MsgBox("Searching", MsgBoxStyle.Information, "Searching...") : Dim intCounter As Integer = 0 : For intCounter = 0 To (intTotalRec - 1) : lblRecNo.Text = intCurrentRec + 1 : lblTotalRec.Text = intTotalRec : 'SNAG when .text boxes = strStockSearch : If (txtStatus2.Text = ("" & strStockSearch)) Then : MsgBox("FOUND MATCH", MsgBoxStyle.Exclamation, "FOUND MATCH") : Else : : End If : intCurrentRec = intCurrentRec + 1 : Me.BindingContext(DataSet11, "mdbShaun").Position = tCurrentRec : Next : MsgBox("Finished Searching.", MsgBoxStyle.Information, "Finished.") : intCurrentRec = 0 : lblRecNo.Text = intCurrentRec + 1 : Me.BindingContext(DataSet11, "mdbShaun").Position = 0 : End Sub :
    :
    : : Hi,
    : :
    : : I am using Dataset and Windows Form and want to use relative search using search key. Yes of course i can move the record pointer using absolute position, but i could not get any method or class associated with dataset to find using a search key.
    : :
    : :

    This seems like a whole lot of code to do the same thing I showed in the previous reply, just an opinion though. I am glad that it works for you.

    \--||--//

    //--||--\

Sign In or Register to comment.