9 Replies - 1960 Views - Last Post: 16 October 2012 - 06:05 PM Rate Topic: -----

#1 CoryCarlson  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 14-October 12

Storing XML info into database.

Posted 14 October 2012 - 11:28 AM

I am trying to store data from an XML RSS feed into a created database and dataset. The location of the XML feed is(http://dev.rotoworld.com/rss/feed.aspx?sport=nfl&ftype=news&count=12&format=rss). I am trying to databind a listbox and a text box to the information in the database. The database is named RSS.mdf and the dataset is RSSdataset.xsd. I have tried to use a datagridview to populate the boxes and have been successful populationg the listbox witht this method, however I cannot populate the text box with different information. The listbox needs to contain the title of the article in the RSS and the text box needs to contain the description of the article selected in the listbox. If I could get the database populated with this information I can bind them to the controls. the tables in my list box are "Articles" and "Description". they both contain the columns Article, ArticleID, Description, and Link. Here is the code I have using the datagrid.
 Dim ds As DataSet = New DataSet



        ds.ReadXml("http://www.rotoworld.com/rss/feed.aspx?sport=nfl&ftype=news&count=12&format=rss")



        DataGridView1.DataSource = ds.Tables("item")


        ListBox1.DataSource = ds.Tables("item")
        ListBox1.DisplayMember = "title"
        ListBox1.ValueMember = "title"
        ListBox1.Refresh()


        ListBox2.DataSource = ds.Tables("item")
        ListBox2.DisplayMember = "description"
        ListBox2.ValueMember = "description"
        ListBox2.Refresh()


    


CORRECTION The tables are in the database, not the listbox.

Is This A Good Question/Topic? 0
  • +

Replies To: Storing XML info into database.

#2 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1623
  • View blog
  • Posts: 5,200
  • Joined: 25-September 09

Re: Storing XML info into database.

Posted 14 October 2012 - 12:28 PM

So if I understand you right, you want when you select an item in the listbox, that the textbox automatically updates to what is is the description column for that row? If that's correct then you need to set up databinding for your textbox.
TextBox1.DataBindings.Add({property you want to bind}, {datasource}, {column AKA DataMember})

In this case, you want to bind the .Text property so all you should have to do is:
TextBox1.DataBindings.Add("Text", ds.Tables("item"), "description")
Was This Post Helpful? 1
  • +
  • -

#3 CoryCarlson  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 14-October 12

Re: Storing XML info into database.

Posted 14 October 2012 - 01:03 PM

CharlieMay,
I inserted that code, which makes alot of sense. It still doesnt populate the text box. I feel like I've tried everything. If I could get the xml data into the database I could just bind the boxes...
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1623
  • View blog
  • Posts: 5,200
  • Joined: 25-September 09

Re: Storing XML info into database.

Posted 14 October 2012 - 02:33 PM

You already have a dataset from the link, so you could create a database that matches the layout (link, description, etc...) connect to it via the dataadapter and fill a new ds (which will be empty but will have the data structure)

Then copy the dataset from the XML to your new dataset and update the dataadapter with your new recordset and your table would be populated with this information.

EDIT:
so you're saying the example I gave above did not populate a textbox with the description of the selected row?
Show the code you tried.
I just copied your code to a solution and added the DGV and two listboxes and a textbox and when I seleted from any of the 3 objects, the textbox populates with the description.

This post has been edited by CharlieMay: 14 October 2012 - 02:47 PM

Was This Post Helpful? 1
  • +
  • -

#5 CoryCarlson  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 14-October 12

Re: Storing XML info into database.

Posted 14 October 2012 - 03:20 PM

This is what I put.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'RssdbDataSet.Articles' table. You can move, or remove it, as needed.
        Me.ArticlesTableAdapter.Fill(Me.RssdbDataSet.Articles)
       

        Dim ds As DataSet = New DataSet



        ds.ReadXml("http://www.rotoworld.com/rss/feed.aspx?sport=nfl&ftype=news&count=12&format=rss")



        DataGridView1.DataSource = ds.Tables("item")


        ListBox1.DataSource = ds.Tables("item")
        ListBox1.DisplayMember = "title"
        ListBox1.ValueMember = "title"
        ListBox1.Refresh()

        WebBrowser1.DataBindings.Add("url", ds.Tables("item"), "link")



        TextBox1.DataBindings.Add("Text", ds.Tables("item"), "description")

Was This Post Helpful? 0
  • +
  • -

#6 CoryCarlson  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 14-October 12

Re: Storing XML info into database.

Posted 14 October 2012 - 03:28 PM

View PostCharlieMay, on 14 October 2012 - 02:33 PM, said:

I just copied your code to a solution and added the DGV and two listboxes and a textbox and when I seleted from any of the 3 objects, the textbox populates with the description.



You're right, I created a form from scratch and pasted the code. It worked this time. awesome. I am wondering why it didnt before..
Was This Post Helpful? 0
  • +
  • -

#7 CoryCarlson  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 14-October 12

Re: Storing XML info into database.

Posted 15 October 2012 - 01:05 PM

Why does the code in line 22 above not work for the webbrowser1?
Was This Post Helpful? 0
  • +
  • -

#8 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1623
  • View blog
  • Posts: 5,200
  • Joined: 25-September 09

Re: Storing XML info into database.

Posted 15 October 2012 - 04:52 PM

Well, the webbrowswer.URL property requires a URI you are passing it a string.

For example, if you were to put WebBrowser1.Url = "www.google.com" with Option Strict On, you would receive an error that a String cannot be converted to URI. To resolve this, WebBrowser1.Url = New Uri("www.google.com") would work.

To do this through databinding is beyond me. But you should be able to get the link either from the database or the datagridview and use it as the string parameter in the URI

This post has been edited by CharlieMay: 15 October 2012 - 05:02 PM

Was This Post Helpful? 1
  • +
  • -

#9 CoryCarlson  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 14-October 12

Re: Storing XML info into database.

Posted 16 October 2012 - 05:42 PM

Charlie May,
a friend helped me out. The following worked.

MainForm.WebBrowser1.DataBindings.Add("Url", ds.Tables("item"), "link", True)


This enables formatting of the value which invokes the property's TypeConverter.
Was This Post Helpful? 1
  • +
  • -

#10 CharlieMay  Icon User is online

  • This space intentionally left blank
  • member icon

Reputation: 1623
  • View blog
  • Posts: 5,200
  • Joined: 25-September 09

Re: Storing XML info into database.

Posted 16 October 2012 - 06:05 PM

I'll have to check that out because I honestly had no clue what to try there. Thanks for the tip.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1