Avatar of Victor  Charles
Victor Charles
Flag for United States of America asked on

Help with displaying partial column name from xml file in combobox using vb.net

Hi,

How do I modify the code below to only display the first 5 records in a table and also from the  to the 12th record. i need to display records in a combobox depending on which categories chosen.

 Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
        Dim xmlPath1 As String
        Dim dtsetcol1 As New DataSet
        xmlPath1 = System.IO.Path.Combine(Application.StartupPath + "\MainTest.xml")  'grid1
        dtsetcol1.Clear()
        dtsetcol1.ReadXml(xmlPath1)
        Me.ComboBox3.DataSource = dtsetcol1.Tables(0).Columns(0).ColumnName
    End Sub

Thanks,

Victor
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
Fernando Soto

8/22/2022 - Mon
Fernando Soto

Hi Victor;

To part of your question, "How do I modify the code below to only display the first 5 records ", The way you are loading the records does not allow for filtering the rows during the load. You can try removing the rows from the XML before loading or you can try removing/deleting the rows after the rows have been added.

To this part of the question, "also from the  to the 12th record. i need to display records in a combobox depending on which categories chosen", do you mean "from the X  to the 12th record." where X is a number from 0 to 11 and is determine at run time or something else?
Victor Charles

ASKER
Hi Fernando,

Yes, x is a number from 0 and 11 and determined at run time, how do you remove the columns from the xml file and save yhe new file to a temp table to displays the records?

Thanks,

Victor
Fernando Soto

That would depend on the schema / structure of the XML. Please post an accurate representation of the XML file so I can show you how.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Victor Charles

ASKER
Hi Fernando,

Below is the structure of the xml file.

 <Root>
<Fields>
<FieldsN>SN</FieldsN>
</Fields>
<Fields>
 <FieldsN>COUNTRY</FieldsN>
</Fields>
<Fields>
   <FieldsN>AGD4</FieldsN>  
</Fields>
<Fields>
 <FieldsN>FIF</FieldsN>
</Fields>
<Fields>
<FieldsN>NSN</FieldsN>  
</Fields>
<Fields>
 <FieldsN>RN</FieldsN>  
</Fields>
<Fields>
<FieldsN>NAS</FieldsN>
</Fields>
 </Root>

Thanks,

Victor
Fernando Soto

How will you want the list to be filtered / delete items so that they don't show up in the ComboBox?
Victor Charles

ASKER
Hi Fernando,

Sorry for the late reply, Is it possible for the temp table to only contain the records I want to display?

Thanks,

Victor
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Fernando Soto

To your question, "Sorry for the late reply, Is it possible for the temp table to only contain the records I want to display? ", In short the answer is Yes. But that also will depend on what Temp Table is? Is it a .Net DataTable object, or an SQL Temp Table or something else and how you will be filtering the rows for the ones you want to display.
Victor Charles

ASKER
Hi Fernando,

In previous post you suggested it may be best to delete the rows of the records I don't want to display, I would like to access to new file with deleted rows to a temp table using the .NET DataTable.

Thanks,

Victor
ASKER CERTIFIED SOLUTION
Fernando Soto

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Victor Charles

ASKER
Yes. Thank you.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Fernando Soto

Hi Victor; if that answered your question please close the question. Thank you.
Victor Charles

ASKER
Thank Yoi.
Fernando Soto

Not a problem Victor.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.