469,573 Members | 1,704 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

Working with a single record resultset vs multi record

Hi,

In all my coding to date, i have been dealing with multiple results in my
dataset, looping through them with

SqlDataAdapterContactProfile.Fill(contact, "Profile")

For Each pRow In contact.Tables("Profile").Rows

label1.text = prow("fieldname")

Next
I now have a situation where I only return a single record, and want to know
how i should deal with this situation. There is no point having a for each
loop
as there is only the one row.

What code should I have so that I can access the single record result set

Thanks
Jun 5 '07 #1
6 2339
Aussie Rules wrote:
Hi,

In all my coding to date, i have been dealing with multiple results in my
dataset, looping through them with
You mean a single result with multiple rows. Multiple results would mean
that you would have multiple Table objects in the DataSet.
SqlDataAdapterContactProfile.Fill(contact, "Profile")

For Each pRow In contact.Tables("Profile").Rows

label1.text = prow("fieldname")

Next
I now have a situation where I only return a single record, and want to
know
how i should deal with this situation. There is no point having a for
each loop
as there is only the one row.

What code should I have so that I can access the single record result set
Just access the first row (index 0):

label1.Text = contact.Tables("Profile").Rows(0).Item("fieldname" )

or

label1.Text = contact.Tables("Profile").Rows(0)("fieldname")
If you want to access more than one field, you might want to create a
reference to the row:

Dim profile As DataRow = contact.Tables("Profile").Rows(0)
label1.Text = profile("fieldname")

--
Göran Andersson
_____
http://www.guffa.com
Jun 5 '07 #2
Aussie Rules wrote:
Hi,

In all my coding to date, i have been dealing with multiple results in my
dataset, looping through them with

SqlDataAdapterContactProfile.Fill(contact, "Profile")

For Each pRow In contact.Tables("Profile").Rows

label1.text = prow("fieldname")

Next
I now have a situation where I only return a single record, and want to
know
how i should deal with this situation. There is no point having a for
each loop
as there is only the one row.

What code should I have so that I can access the single record result set
I think this link will put you into the ballpark.

<http://www.aspfree.com/c/a/MS-SQL-Server/Pulling-Information-using-DataAdapter-with-ADONET/2/>

http://preview.tinyurl.com/ysos8p
Jun 5 '07 #3
Darnold

There are AFAIK only two methods to Find a row. That is using the DataView
which returns the position in the dataview and the find in the
datarowcollection which returns a datarow.
All others return a collection of rows.

http://www.vb-tips.com/dbpages.aspx?...d-13dccb86d378

I hope this helps,

Cor

"DArnold" <DA*****@DArnold.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
Aussie Rules wrote:
>Hi,

In all my coding to date, i have been dealing with multiple results in my
dataset, looping through them with

SqlDataAdapterContactProfile.Fill(contact, "Profile")

For Each pRow In contact.Tables("Profile").Rows

label1.text = prow("fieldname")

Next
I now have a situation where I only return a single record, and want to
know
how i should deal with this situation. There is no point having a for
each loop
as there is only the one row.

What code should I have so that I can access the single record result set

I think this link will put you into the ballpark.

<http://www.aspfree.com/c/a/MS-SQL-Server/Pulling-Information-using-DataAdapter-with-ADONET/2/>

http://preview.tinyurl.com/ysos8p

Jun 5 '07 #4
Sorry,

This is not meant as a correction or whatever, just attached to the wrong
thread while your message was open, should have been to the main thread.

Cor

"Cor Ligthert [MVP]" <no************@planet.nlschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
Darnold

There are AFAIK only two methods to Find a row. That is using the DataView
which returns the position in the dataview and the find in the
datarowcollection which returns a datarow.
All others return a collection of rows.

http://www.vb-tips.com/dbpages.aspx?...d-13dccb86d378

I hope this helps,

Cor

"DArnold" <DA*****@DArnold.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Aussie Rules wrote:
>>Hi,

In all my coding to date, i have been dealing with multiple results in
my
dataset, looping through them with

SqlDataAdapterContactProfile.Fill(contact, "Profile")

For Each pRow In contact.Tables("Profile").Rows

label1.text = prow("fieldname")

Next
I now have a situation where I only return a single record, and want to
know
how i should deal with this situation. There is no point having a for
each loop
as there is only the one row.

What code should I have so that I can access the single record result
set

I think this link will put you into the ballpark.

<http://www.aspfree.com/c/a/MS-SQL-Server/Pulling-Information-using-DataAdapter-with-ADONET/2/>

http://preview.tinyurl.com/ysos8p


Jun 5 '07 #5
Cor Ligthert [MVP] wrote:
Darnold

There are AFAIK only two methods to Find a row. That is using the DataView
which returns the position in the dataview and the find in the
datarowcollection which returns a datarow.
All others return a collection of rows.

http://www.vb-tips.com/dbpages.aspx?...d-13dccb86d378

I hope this helps,

Cor
Perhaps you replied in the wrong thread? He's not trying to find
anything at all. He only has a single row, so it's not very hard to find
it...
"DArnold" <DA*****@DArnold.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Aussie Rules wrote:
>>Hi,

In all my coding to date, i have been dealing with multiple results in my
dataset, looping through them with

SqlDataAdapterContactProfile.Fill(contact, "Profile")

For Each pRow In contact.Tables("Profile").Rows

label1.text = prow("fieldname")

Next
I now have a situation where I only return a single record, and want to
know
how i should deal with this situation. There is no point having a for
each loop
as there is only the one row.

What code should I have so that I can access the single record result set
I think this link will put you into the ballpark.

<http://www.aspfree.com/c/a/MS-SQL-Server/Pulling-Information-using-DataAdapter-with-ADONET/2/>
>>
http://preview.tinyurl.com/ysos8p


--
Göran Andersson
_____
http://www.guffa.com
Jun 5 '07 #6
You are right

"Göran Andersson" <gu***@guffa.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
Cor Ligthert [MVP] wrote:
>Darnold

There are AFAIK only two methods to Find a row. That is using the
DataView which returns the position in the dataview and the find in the
datarowcollection which returns a datarow.
All others return a collection of rows.

http://www.vb-tips.com/dbpages.aspx?...d-13dccb86d378

I hope this helps,

Cor

Perhaps you replied in the wrong thread? He's not trying to find anything
at all. He only has a single row, so it's not very hard to find it...
>"DArnold" <DA*****@DArnold.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>Aussie Rules wrote:
Hi,

In all my coding to date, i have been dealing with multiple results in
my
dataset, looping through them with

SqlDataAdapterContactProfile.Fill(contact, "Profile")

For Each pRow In contact.Tables("Profile").Rows

label1.text = prow("fieldname")

Next
I now have a situation where I only return a single record, and want to
know
how i should deal with this situation. There is no point having a for
each loop
as there is only the one row.

What code should I have so that I can access the single record result
set
I think this link will put you into the ballpark.

<http://www.aspfree.com/c/a/MS-SQL-Server/Pulling-Information-using-DataAdapter-with-ADONET/2/>
>>>
http://preview.tinyurl.com/ysos8p



--
Göran Andersson
_____
http://www.guffa.com

Jun 6 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by canigou9 (remove your socks to reply) | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.