What am I doing wrong?

  • Thread starter Thread starter cjobes
  • Start date Start date
C

cjobes

Hi all,

The code below is part of a form where I would like the user to make
selections from a table. The data is brought into the form from another form
with:
Public WriteOnly Property DataSet() As DataSet
Set(ByVal Value As DataSet)
ResultGrid.DataSource = Value.Tables("tbSelect")
End Set
End Property

When the user clicks on a button "New Filter" the code below runs. On the
line "ResultGrid.DataMember = "tbTemp" the execution stops with the
following error: "Can't create a child list for field tbTemp"


Private Sub btNewFilter_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btNewFilter.Click
Dim uSelect As String = "cindih"
ResultGrid.Visible = False
Dim strSearch As String = "user='" + uSelect + "'"
_dt = ResultGrid.DataSource
Dim tbTemp As DataTable
tbTemp = _dt.Clone()
Dim dRows() As DataRow = _dt.Select(strSearch, "")
Dim drSel As DataRow
For Each drSel In dRows
If Not drSel("hours") Is System.DBNull.Value Then
totHours = totHours + drSel("hours")
Else
drSel("hours") = 0
End If
tbTemp.ImportRow(drSel)
Next
ResultGrid.DataMember = "tbTemp"
ResultGrid.Visible = True
End Sub

What am I doing wrong here?

Thanks
Claus
 
Replace the line: ResultGrid.DataMember = "tbTemp"
with: ResultGrid.DataSource = tbTemp

If the DataSource of a DataGrid is a DataTable, just set the property
directly to the Datatable.

If the DataSource of a DataGrid is a DataSet, then you can specify which
table in the DataSet you want to display using the DataMember property. The
TableName property for the DataTable within the DataSet would have to be set
also:

DS.Tables.Add(DT)
DS.Tables(0).TableName = "DT"
DG.DataSource=DS
DG.DataMember="DT"

www.charlesfarriersoftware.com
 
Charlie,

You don't have any idea how grateful I am for your answer. I don't know how
many hours I have been trying to figure this one out. MSDN wasn't helpful
either.

Thanks again,

Claus
 
Claus,

The problem with most samples from MSDN is that they are with strongly typed
dataset and with let say raw datasets.

I mostly use in all my samples raw datasets. However because you started to
make a strongly typed dataset I went on that route. In the way I showed you
that sample, you can forever use the top reference of that strongly typed
dataset, therefore something as

ds.tables("KlausTable") in a table in the dataset while when you make it
strongly typed yuursel fit can be ds.KlausTable

a reference to a table can forever been set as
dim myTableRef as datatable = ds.tables("KlausTable")

I hope this gives some ideas.

Cor
 
Cor Ligthert said:
... you can forever use the top reference ...

(you can always use the top reference)
... a table can forever been set as

(a table can always be set as)

Since you provide so many answers, it will be a big help
if we can slowly help you to post fluent English! :-)

Always - is conditional (in all ways..., at all times..., in all cases... etc.)
Forever - is a never ending expanse of time

EX1:
While humans must always breathe, no one breathes forever.
EX2:
These newsgroup posts always get copied to the Google
archive and may be forever available to everyone.


HTH
LFS
 
Larry,

I will keep an eye on it, my dictionary gives for both almost the same
translation word, in transslated words "all times" (still and will be) and
for ever = "all times" (start and endless). While the say that forever is
the same as ever.

However I will try to keep an eye on it.

The samples are clear, to translate them checking

Always continuing as long as is
Forever a fact

Thanks,

Cor
 
Larry,

While *they* say that forever is the same as "ever".
Only a typo.

By the way before you misunderstood this, "always" an "forever" is
translated as "altijd" in Dutch "al" = English "All" and "tijd" = "time".

Again thanks.

Cor
 
Hi Cor,

Guess I have figured out what neck of the woods you are in. Where in Holland
are you?

I'm in your Neighbourhood next week (France and Germany) with plane changes
in Amsterdam and Paris.

Claus
 
Hi,

Claus, interesting, I am almost true in the woods of Holland yes (and there
is not much wood here).

Amsterdam and Paris are my favorite places so I can only tell you that that
cannot be a bad idea.

Amsterdam
Nightlive, culture
Paris
Culture, shoping

There are a lot of other good places in Europe, however those two above are
my favorites.

However a little bit of object here these messages

:-))

Cor
 
Back
Top