Dataset, Select, XMHelL

J

James Chambers

Ok, I have been beating my head against the monitor now for weeks. My
family no longer recognizes me and I am hearing tales about Uncle Bob
coming to visit even. This can't be this hard. I have a significant
amount of experience programming with VB 4 and 5. That, of course, was
about 6 years ago before I moved into infrastructure support. I bought
a Hauppauge PVR 150 and quickly decided I wanted functionality similar
to my Tivo in that when I enter shows, it will record them whenever they
are on. XMLTV provides listings in XML format. I thought it was a good
reason to dip back into my programming skills. After all, XML is the
big buzz word. I went out and bought VB .Net and here I am.

Here's what I am trying to do... I want to read in the XML Schema and
Data, assign it to a Dataset bound to a DataGrid. From there, I want to
be able to select items based on the title_Text field of the title table
and display the results into a DataGrid. I do OK until I try to display
the results. When I do, I only get the results of the titles table, not
the related data. Below, I'll post the relevant code... As always, any
help appreciated.

Public Class Form1
Inherits System.Windows.Forms.Form
Dim dsXMLTV As New DataSet("xmltv")

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Load dataset with file from XMLTV
dsXMLTV.ReadXmlSchema("c:\xmltv\tv.xml")
dsXMLTV.ReadXml("c:\xmltv\tv.xml")
' Using DataGrid, display data from dataset
With DataGrid1
.DataSource = dsXMLTV.DefaultViewManager
.DataMember = "programme"
.CaptionText = .DataMember
End With
End Sub

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnSearch.Click

' Search for Monster Garage as a test
With dsXMLTV.Tables("title")
.DefaultView.RowFilter = "title_Text like 'Monster Garage'"
If .DefaultView.Count = 0 Then
MessageBox.Show("No matching rows.", "Alert",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
DataGrid1.DataSource = .DefaultView
' When this is executed, all I get is a list of titles.
End With

End Sub

End Class
 
C

Cor Ligthert

James,

First why are you using those terrible "with's" It makes your program not
more readable, will not speed up your program at all and cost only more
typing.

Probably when you have only one table, than the problem is the Rowfilter .
Start with putting a ' before the syntax temporaly. I thought that the Like
was not such a strong operator as you assume probably now. I would surely
look the documentation about that. In my opinion did you not write it well.
It is more as Like *me*.

I hope this helps,

Cor
 
J

James Chambers

Cor said:
James,

First why are you using those terrible "with's" It makes your program not
more readable, will not speed up your program at all and cost only more
typing.

Probably when you have only one table, than the problem is the Rowfilter .
Start with putting a ' before the syntax temporaly. I thought that the Like
was not such a strong operator as you assume probably now. I would surely
look the documentation about that. In my opinion did you not write it well.
It is more as Like *me*.

I hope this helps,

Cor

I cleaned it up and removed the With's as you suggested. I also updated
the rowfilter to read '%Monster Garage%' as the other reply suggested.
Still not successful. When the dataset reads the XML file in, it places
the data in several tables.
 
C

Cor Ligthert

James,

My main intention was to try it first withouth that rowfilter.

Than we know if the problem is in the rowfilter or somewhere else.

Cor
 
J

James Chambers

Cor said:
James,

My main intention was to try it first withouth that rowfilter.

Than we know if the problem is in the rowfilter or somewhere else.

Cor


Sorry, I misunderstood. I just commented out the rowfilter line and it
acts the same. So the problem is elsewhere. Would posting the schema
be helpful? I could also post some screenshots on my website so you can
see exactly what it's doing if that would help.

Thanks!
 
C

Cor Ligthert

James,

This should forever give something on your datagrid.

DataGrid1.DataSource = dsXMLTV

And than comment out that Datagrid.member and caption.

Cor
 

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

Top