473,473 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataTable.Select

Could someone please help me? I have searched everywhere
but couldn't find definite answers. I am trying to read
xml file to a dataset and select from it. Here's xml
file:

<?xml version="1.0" encoding="utf-8" ?>
<root>
<data>
<id>1</id>
<name>Tae Lee</name>
</data>
<data>
<id>2</id>
<name>Tae Sung Lee</name>
</data>
</root>

Then here's the code.

Dim ds As New Data.DataSet
ds.ReadXml("data.xml")
Dim dt As DataTable = ds.Tables("data")
Dim str As String = "id = 2"
Dim dr As Data.DataRow = dt.Select(str)
Literal1.Text = dr.Item(1)

The problem is that when you select from datatable, the
result is 1-dimensional array of data row. So I get an
error when I attempt to put array into a row. If you
have any similar experience, please let me know. Thank
you so much.

-Tae Lee
Nov 20 '05 #1
2 2675
"Tae Lee" <sq*******@hotmail.com> wrote in message
news:01****************************@phx.gbl...
Could someone please help me? I have searched everywhere
but couldn't find definite answers. I am trying to read
xml file to a dataset and select from it. Here's xml
file:

<?xml version="1.0" encoding="utf-8" ?>
<root>
<data>
<id>1</id>
<name>Tae Lee</name>
</data>
<data>
<id>2</id>
<name>Tae Sung Lee</name>
</data>
</root>

Then here's the code.

Dim ds As New Data.DataSet
ds.ReadXml("data.xml")
Dim dt As DataTable = ds.Tables("data")
Dim str As String = "id = 2"
Dim dr As Data.DataRow = dt.Select(str)
Literal1.Text = dr.Item(1)

The problem is that when you select from datatable, the
result is 1-dimensional array of data row. So I get an
error when I attempt to put array into a row. If you
have any similar experience, please let me know. Thank
you so much.

-Tae Lee


If you assume that you are always returning exactly one result, then you can
do this:

Dim dr as Data.DataRow = dt.Select(str)(0)

Just make sure you are always getting back exactly one result!

Erik
Nov 20 '05 #2
Cor
Hi Tae,
Dim str As String = "id = 2"
Dim dr As Data.DataRow = dt.Select(str)
Literal1.Text = dr.Item(1)
It has to be a datarow collection and therefore Dim str As String = "id = 2"
Dim drcollection() As Data.DataRow = dt.Select(str) if drcollection.length > 0 then
dim dr as datarow = drcollection(0)
Literal1.Text = dr.Item(1)
'or if you wish literal1.text = drcollection(0)(1)
end if

I hope this helps?
Cor
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: randy | last post by:
Hello all, I have a DataTable which I am building column by column and adding rows after each new column. The DataTable columns match the columns in my database table. I'm building the...
5
by: Stefan Turalski \(stic\) | last post by:
Hi, I'm wondering if there is a way to send a method parametrs by ref when DataTabel is a type of this value ? I done some sort of select over DataTable columns, just by removing them froma...
3
by: nandan | last post by:
Hi, Has any one ever compared the performance of calling a DataTable's Select method with a stored procedure doing the same thing? My point is: dataRows = DataTable.Select(filter) is better or...
4
by: Kris Rudin | last post by:
I am displaying a table of information on a web page, using an asp:table that I populate dynamically. On this page I give the user the options to group the rows by certain fields, and/or filter the...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
2
by: JohnR | last post by:
Sorry if this is has an obvious answer, but I can't find it... I am using a datatable.select to obtain the rows in a datatable that meet certain criteria. My question is this: for each of the...
7
by: wk6pack | last post by:
Hi, How do I check datatable.select(filter) in the following: for each dtrow in datatable.select(filter) .... next I've also tried:
6
by: Pete Wittig | last post by:
Hi, I have a DataTable and I want to get a subset of the rows within it. I use the Select method to get my subset and the results are in a DataRow. I want to put those Rows back into a...
1
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the...
6
by: fniles | last post by:
I am using VB.NET 2005 and Access database. My program uses a timer that kicks in every 1 min to read from a database and copy the dataset table to a datatable. This database is in a class called...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.