By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,383 Members | 2,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,383 IT Pros & Developers. It's quick & easy.

Filter Data

P: n/a
Hi gurus,
How can I filter data in my DataSet and then put the result in a DataGrid?
NOTE: I'm reading a txt file into a dataset with 3 columns:

Id, Name, Age

I have this:
code------------------------------------------------------------------------
-----------------------
LerLinha = New StreamReader(LerPath)

dsMrc = New DataSet
dtMrc = New DataTable("Mrc")
dcMrc = New DataColumn("Id",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Name",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Age",
System.Type.GetType("System.String"))

dtMrc.Columns.Add("Id")
dtMrc.Columns.Add("Name")
dtMrc.Columns.Add("Age")

dsMrc.Tables.Add(dtMrc)

Do
txtLine = LerLinha.ReadLine()

drMrc = dtMrc.NewRow()
drMrc("Id") = ProcessId(txtLine) 'FindUser
drMrc("Name") = ProcessName(txtLine)
drMrc("Age") = ProcessAge(txtLine)
dtMrc.Rows.Add(drMrc)

dsMrc.Tables("Mrc").Rows.Add(drMrc)
Loop Until txtLine Is Nothing

Dim strFilter As String

strFilter = "Id=" & FindUser

dsMrc.Tables("Mrc").Select(strFilter)

dgMarcacoes.DataSource = dsMrc

LerLinha.Close()
LerLinha = Nothing
code------------------------------------------------------------------------
-----------------------
What's wrong??????

--

Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca
Nov 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
<snip>
dsMrc.Tables("Mrc").Select(strFilter) <snip> What's wrong??????


The Select method on the DataTable class returns an array of DataRow objects
that match the filter criteria. You should use the returned array. The call
to Select doesn't modify the DataTable itself.

Greetings
Martin
Nov 18 '05 #2

P: n/a
Maybe I'm missing something, but in the posted code, i dont think the
"Finduser" variable is set.

"ruca" <ru***@iol.pt> wrote in message
news:uh*************@TK2MSFTNGP09.phx.gbl...
Hi gurus,
How can I filter data in my DataSet and then put the result in a DataGrid?
NOTE: I'm reading a txt file into a dataset with 3 columns:

Id, Name, Age

I have this:
code------------------------------------------------------------------------ -----------------------
LerLinha = New StreamReader(LerPath)

dsMrc = New DataSet
dtMrc = New DataTable("Mrc")
dcMrc = New DataColumn("Id",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Name",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Age",
System.Type.GetType("System.String"))

dtMrc.Columns.Add("Id")
dtMrc.Columns.Add("Name")
dtMrc.Columns.Add("Age")

dsMrc.Tables.Add(dtMrc)

Do
txtLine = LerLinha.ReadLine()

drMrc = dtMrc.NewRow()
drMrc("Id") = ProcessId(txtLine) 'FindUser
drMrc("Name") = ProcessName(txtLine)
drMrc("Age") = ProcessAge(txtLine)
dtMrc.Rows.Add(drMrc)

dsMrc.Tables("Mrc").Rows.Add(drMrc)
Loop Until txtLine Is Nothing

Dim strFilter As String

strFilter = "Id=" & FindUser

dsMrc.Tables("Mrc").Select(strFilter)

dgMarcacoes.DataSource = dsMrc

LerLinha.Close()
LerLinha = Nothing
code------------------------------------------------------------------------ -----------------------
What's wrong??????

--

Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Nov 18 '05 #3

P: n/a
forget FindUser :). In fact it's comment

ruca

"Felbrigg" <so*****@microsoft.com> escreveu na mensagem
news:uS**************@TK2MSFTNGP10.phx.gbl...
Maybe I'm missing something, but in the posted code, i dont think the
"Finduser" variable is set.

"ruca" <ru***@iol.pt> wrote in message
news:uh*************@TK2MSFTNGP09.phx.gbl...
Hi gurus,
How can I filter data in my DataSet and then put the result in a DataGrid? NOTE: I'm reading a txt file into a dataset with 3 columns:

Id, Name, Age

I have this:

code------------------------------------------------------------------------
-----------------------
LerLinha = New StreamReader(LerPath)

dsMrc = New DataSet
dtMrc = New DataTable("Mrc")
dcMrc = New DataColumn("Id",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Name",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Age",
System.Type.GetType("System.String"))

dtMrc.Columns.Add("Id")
dtMrc.Columns.Add("Name")
dtMrc.Columns.Add("Age")

dsMrc.Tables.Add(dtMrc)

Do
txtLine = LerLinha.ReadLine()

drMrc = dtMrc.NewRow()
drMrc("Id") = ProcessId(txtLine) 'FindUser
drMrc("Name") = ProcessName(txtLine)
drMrc("Age") = ProcessAge(txtLine)
dtMrc.Rows.Add(drMrc)

dsMrc.Tables("Mrc").Rows.Add(drMrc)
Loop Until txtLine Is Nothing

Dim strFilter As String

strFilter = "Id=" & FindUser

dsMrc.Tables("Mrc").Select(strFilter)

dgMarcacoes.DataSource = dsMrc

LerLinha.Close()
LerLinha = Nothing

code------------------------------------------------------------------------
-----------------------
What's wrong??????

--

Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca


Nov 18 '05 #4

P: n/a
But, how can I put it into a DataGrid?

"Martin Dechev" <de*******@hotmail.com> escreveu na mensagem
news:Om**************@TK2MSFTNGP09.phx.gbl...
<snip>
dsMrc.Tables("Mrc").Select(strFilter) <snip>
What's wrong??????


The Select method on the DataTable class returns an array of DataRow

objects that match the filter criteria. You should use the returned array. The call to Select doesn't modify the DataTable itself.

Greetings
Martin

Nov 18 '05 #5

P: n/a
The way I'm doing, nothing appears and I have Data there.
"Martin Dechev" <de*******@hotmail.com> escreveu na mensagem
news:Om**************@TK2MSFTNGP09.phx.gbl...
<snip>
dsMrc.Tables("Mrc").Select(strFilter) <snip>
What's wrong??????


The Select method on the DataTable class returns an array of DataRow

objects that match the filter criteria. You should use the returned array. The call to Select doesn't modify the DataTable itself.

Greetings
Martin

Nov 18 '05 #6

P: n/a
Ruca:
"ruca" <ru***@iol.pt> wrote in message
news:uh*************@TK2MSFTNGP09.phx.gbl...
Hi gurus,
How can I filter data in my DataSet and then put the result in a DataGrid?
NOTE: I'm reading a txt file into a dataset with 3 columns:

Id, Name, Age

I have this:
code------------------------------------------------------------------------ -----------------------
LerLinha = New StreamReader(LerPath)

dsMrc = New DataSet
dtMrc = New DataTable("Mrc")
dcMrc = New DataColumn("Id",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Name",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Age",
System.Type.GetType("System.String"))

dtMrc.Columns.Add("Id")
dtMrc.Columns.Add("Name")
dtMrc.Columns.Add("Age")

dsMrc.Tables.Add(dtMrc)

Do
txtLine = LerLinha.ReadLine()

drMrc = dtMrc.NewRow()
drMrc("Id") = ProcessId(txtLine) 'FindUser
drMrc("Name") = ProcessName(txtLine)
drMrc("Age") = ProcessAge(txtLine)
dtMrc.Rows.Add(drMrc)

dsMrc.Tables("Mrc").Rows.Add(drMrc)
Loop Until txtLine Is Nothing

Dim strFilter As String

strFilter = "Id=" & FindUser

dsMrc.Tables("Mrc").Select(strFilter)

dgMarcacoes.DataSource = dsMrc

LerLinha.Close()
LerLinha = Nothing
code------------------------------------------------------------------------ -----------------------
What's wrong??????

--

Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca


you may want to consider binding the grid to a DataView which is based on a
DataTable in your Dataset and then just changing the rowfilter. If you do
this, the filtered data will be reflected immediately. Just set the Grid's
DataSource property to the DataView and use something like this
http://www.knowdotnet.com/articles/a...rowfilter.html
Nov 18 '05 #7

P: n/a
Could be like this....

Dim v as new DataView()
v.table = dsMrc.Tables("Mrc")
v.RowFilter = "Id=" & FindUser
dgMarcacoes.DataSource = v
"ruca" <ru***@iol.pt> wrote in message
news:uh*************@TK2MSFTNGP09.phx.gbl...
Hi gurus,
How can I filter data in my DataSet and then put the result in a DataGrid?
NOTE: I'm reading a txt file into a dataset with 3 columns:

Id, Name, Age

I have this:
code------------------------------------------------------------------------ -----------------------
LerLinha = New StreamReader(LerPath)

dsMrc = New DataSet
dtMrc = New DataTable("Mrc")
dcMrc = New DataColumn("Id",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Name",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Age",
System.Type.GetType("System.String"))

dtMrc.Columns.Add("Id")
dtMrc.Columns.Add("Name")
dtMrc.Columns.Add("Age")

dsMrc.Tables.Add(dtMrc)

Do
txtLine = LerLinha.ReadLine()

drMrc = dtMrc.NewRow()
drMrc("Id") = ProcessId(txtLine) 'FindUser
drMrc("Name") = ProcessName(txtLine)
drMrc("Age") = ProcessAge(txtLine)
dtMrc.Rows.Add(drMrc)

dsMrc.Tables("Mrc").Rows.Add(drMrc)
Loop Until txtLine Is Nothing

Dim strFilter As String

strFilter = "Id=" & FindUser

dsMrc.Tables("Mrc").Select(strFilter)

dgMarcacoes.DataSource = dsMrc

LerLinha.Close()
LerLinha = Nothing
code------------------------------------------------------------------------ -----------------------
What's wrong??????

--

Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca

Nov 18 '05 #8

P: n/a
My drop it isn't show anything, and don't know why.

I understand your code, but not show.

Ruca
"Carlos Campos" <carlos@(NoSpam)costarricense.cr> escreveu na mensagem
news:OY*************@TK2MSFTNGP11.phx.gbl...
Could be like this....

Dim v as new DataView()
v.table = dsMrc.Tables("Mrc")
v.RowFilter = "Id=" & FindUser
dgMarcacoes.DataSource = v
"ruca" <ru***@iol.pt> wrote in message
news:uh*************@TK2MSFTNGP09.phx.gbl...
Hi gurus,
How can I filter data in my DataSet and then put the result in a DataGrid? NOTE: I'm reading a txt file into a dataset with 3 columns:

Id, Name, Age

I have this:

code------------------------------------------------------------------------
-----------------------
LerLinha = New StreamReader(LerPath)

dsMrc = New DataSet
dtMrc = New DataTable("Mrc")
dcMrc = New DataColumn("Id",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Name",
System.Type.GetType("System.String"))
dcMrc = New DataColumn("Age",
System.Type.GetType("System.String"))

dtMrc.Columns.Add("Id")
dtMrc.Columns.Add("Name")
dtMrc.Columns.Add("Age")

dsMrc.Tables.Add(dtMrc)

Do
txtLine = LerLinha.ReadLine()

drMrc = dtMrc.NewRow()
drMrc("Id") = ProcessId(txtLine) 'FindUser
drMrc("Name") = ProcessName(txtLine)
drMrc("Age") = ProcessAge(txtLine)
dtMrc.Rows.Add(drMrc)

dsMrc.Tables("Mrc").Rows.Add(drMrc)
Loop Until txtLine Is Nothing

Dim strFilter As String

strFilter = "Id=" & FindUser

dsMrc.Tables("Mrc").Select(strFilter)

dgMarcacoes.DataSource = dsMrc

LerLinha.Close()
LerLinha = Nothing

code------------------------------------------------------------------------
-----------------------
What's wrong??????

--

Thank's (if you try to help me)
Hope this help you (if I try to help you)
ruca


Nov 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.