Querying a DataSet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I am building an application which needs to search for an address within a
SQL database. The principle is that when you enter the first Alpha charecter
it creates a search string to query the database, there for if you typed in
"10 b" you would retreave all the entries that started with "10 b". However
if I then type in "a" I dont want to re-query that database, instead I want
to query the dataset, i.e. filter all the "10 ba" from the "10 b", and so on.
I can't figure out how to do it.

I hope this make sence.

Does any body have any ideas.

Thanks in advance.


Dave
 
Dave,

See for your question my answer I have send to DC in the message after
yours.

Cor
 
Hi Dave,

I think you're looking for is called a dataview.

Here an example from the help:
Dim custView As DataView = New DataView(custDS.Tables("Customers"), "", _
"CompanyName",
DataViewRowState.CurrentRows)

Dim rowIndex As Integer = custView.Find("The Cracker Box")

If rowIndex = -1 Then
Console.WriteLine("No match found.")
Else
Console.WriteLine("{0}, {1}", _
custView(rowIndex)("CustomerID").ToString(), _
custView(rowIndex)("CompanyName").ToString())
End If
 
Dave,
You can use the DataView to perform the operation that you want. An example
would be:

Private Sub FilterDataTable(SomeDataTable as DataTable, FilterValue as string)
Dim datviewData as DataView
Dim datviewrowData as DataRowView

'create the dataview
datviewData = New DataView(SomeDataTable)

'set the filter
datviewData.Filter = String.Concat("Field_to_filter LIKE '", FilterValue, "%")

'display the data in a list box
For Each datviewrowData in datviewData
lstData.Items.Add(datviewrowData.Item("Field_to_filter"))
Next

End Sub


Hope this helps.

Ajay Mirmira
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top