Select PROBLEM

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

Guest

Hi
i work in VB practicly from the start but I have problem now .... i have dataset in witch i have to tables witch are connected (parent - child) and whan i want to select some rows in child table thosent works. Problem is biger becouse data witch are have to be shown have to be also 'selected' from parent table, mins that have to be only data witch are in that time connected to selected row in parent table. Here is my ? ....

Dim filterExp As String = "Stanje < MinKolicina
Dim drarray() As DataRo
drarray = DsArtikli1.Artikli.Select(filterExp
Me.DataGrid1.DataSource = drarra

after this my datagrid shows some rubish ..
And one more please ... how to make some (witch you chose) rows other color from other rows

Thanks for A
 
Hi Voya,

Confirming the documentation it should work I think also, although they
don't say which properties will be shown in the datagrid.
Dim filterExp As String = "Stanje < MinKolicina"
Dim drarray() As DataRow
drarray = DsArtikli1.Artikli.Select(filterExp)
But I think you can try this to connect to it.
It is not tested in this way, so only written in this message
\\\
Dim dt As New DataTable
dt = dsArtikli.Artikli.clone
Dim x As datarow
For Each x In drarray
Dim dr As DataRow = dt.NewRow
dr = x
dt.Rows.Add(dr)
Next
Me.DataGrid1.DataSource = dt
///
Maybe you can try this.

I hope this will work for you?

If not message it, than I will test it myself?

Cor
 
i try it and it give me some error but i tnihk i give you wrong 'way'... what i need is to show only those rows with some kriteria, and i try with dataview , this is great , it's wotking perfect
for : thanks for everything



Hi Voya,

Confirming the documentation it should work I think also, although they
don't say which properties will be shown in the datagrid.
Dim drarray() As DataRow
drarray = DsArtikli1.Artikli.Select(filterExp)
But I think you can try this to connect to it.
It is not tested in this way, so only written in this message
\\ Dim dt As New DataTable
dt = dsArtikli.Artikli.clone
Dim x As datarow
For Each x In drarray
Dim dr As DataRow = dt.NewRow
dr = x
dt.Rows.Add(dr)
Next
Me.DataGrid1.DataSource = dt
///
Maybe you can try this.

I hope this will work for you?

If not message it, than I will test it myself?

Cor
 
i try it and it give me some error but i tnihk i give you wrong 'way'... what i need is to show only those rows with some kriteria, and i try with dataview , this is great , it's wotking perfect
for : thanks for everything



Hi Voya,

Confirming the documentation it should work I think also, although they
don't say which properties will be shown in the datagrid.

But I think you can try this to connect to it.
It is not tested in this way, so only written in this message
\\ Dim dt As New DataTable
dt = dsArtikli.Artikli.clone
Dim x As datarow
For Each x In drarray
Dim dr As DataRow = dt.NewRow
dr = x
dt.Rows.Add(dr)
Next
Me.DataGrid1.DataSource = dt
///
Maybe you can try this.

I hope this will work for you?

If not message it, than I will test it myself?

Cor

Create a DataRelation between the two tables of your dataset, then use the
GetChildRows method to get an array of child data rows. Example code:

'Assumes you have created a DataRelation object called "RelationName".

Dim rowCust, rowOrder as DataRow
For Each rowCust In ds.Tables("Customers").Rows
'Get child rows (orders)
For Each rowOrder In rowCust.GetChildRows("RelationName")
'Do something with child rows here
Next
Next
 
Hi Chris,

Why you give an answer that has nothing to do with it while the problem is
solved. Voya only told there was a typo in my code and I saw it also I
forgot a 1 with the dataset name.?
i try it and it give me some error but i tnihk i give you wrong
'way'... what i need is to show only those rows with some kriteria, and i
try with dataview , this is great , it's wotking perfect
for : thanks for everything

Cor
..
 
Cor,
Dim dr As DataRow = dt.NewRow
dr = x
You created a new row, then immediately got ride of it, is that what you
really wanted?
dt.Rows.Add(dr)

In addition to the DataTable.Clone method given in the other thread.
DataTable.ImportRow is one easier methods to copy a single row from one
DataTable to another DataTable.

Something like:
For Each x In drarray
Dim dr As DataRow = dt.NewRow dt.ImportRow(dr)
Next

DataTable.LoadDataRow is another option, however if you already have a
DataRow I would opt for the ImportRow.

Hope this helps
Jay
 
Hi Jay B,

I use always a simple commandset and one or two extra commands in this kind
of in memory operations dont botter me.

I tried that import in past and had some trouble with that because it did
not give the right schema, but that was before I know that short method with
the clone.

Your code and that is even not necessary (it does nothing, because you use
an empty datarow, but I think it was the idea about it).
This is possible even less code than you are using.

dt2 = dt.Clone
For Each dr As DataRow In drArr
dt2.ImportRow(dr)
Next

Thank you for making me attend on it.

Cor
 
Cor,
dt2 = dt.Clone
That was implied in your original example.

Of course if you are using DataTable.Rows instead of DataTable.Select, you
can use DataTable.Copy instead of Clone & the loop.

Hope this helps
Jay
 
Why you give an answer that has nothing to do with it

The original poster stated that he was using a dataset with multiple tables
in it using a parent child relationship. The situation he described
indicated to me that a DataRelation and the GetChildRows method of the
dataset would be a possible solution to his problem
while the problem is solved.

I was merely pointing out a possible alternate solution to the one you
gave.

Regards
 
Hi Jay B.

I got the idea you did not see it, this was your code
I changed it to

For each x as datarow in drarray
dt.importrow(x)
next

Your code would import n empty rows.

:-)

Cor
 
Cor,
That's nice! ;-)

Jay

Cor said:
Hi Jay B.

I got the idea you did not see it, this was your code

I changed it to

For each x as datarow in drarray
dt.importrow(x)
next

Your code would import n empty rows.

:-)

Cor
 
Back
Top