473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2474
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: googlinggoogler | last post by:
Hiya, The title says it all really, but im a newbie to python sort of. I can read in files and write files no probs. But what I want to do is read in a couple of files and output them to one...
17
by: Gabriel Mejía | last post by:
Services or applications using ActiveX Data Objects (ADO) 2.0 or greater may intermittently return empty recordsets on queries that should be returning valid results. At the time the problem...
2
by: eeh | last post by:
Hi, Suppose I have a table "product" with fields id,name,price. I want to get a resultset of previous and current and next record when the resultset is sorted by id and id=10. The table data is...
3
by: Paul Janssen | last post by:
Hello! Can anyone help me out with the following situation: (a) a single query with 550 id's in the IN-clause resulting into 800+ seconds; (b) 550 queries with a single id in the IN-clause...
3
by: canigou9 (remove your socks to reply) | last post by:
(cross posted - comp.databases.ms-access, microsoft.public.access) Hello folks - this is my first post here, after a short lurk. I have written an application in Access2002 for a friend's...
24
by: Salad | last post by:
Every now and then I see ads that state something like "Experience with Large Databases ...multi-gig...blah-de-blah" And I have to laugh. What's the difference between a large or small database? ...
2
by: Bob | last post by:
This is the snippet of code Dim myConnString As String = "Integrated Security=SSPI;Packet Size=4096;Data Source=MyServer;" & _ "Initial Catalog=MyDatabase; " & _ "Persist Security...
26
by: Jimmy | last post by:
ill have a database with 1 table and 3 fields: ID FIRSTNAME LASTNAME (the ID field will be the auto incrementing index) there might be 10 records in the DB, there might be 10,000. i...
0
by: loken0673 | last post by:
Hello All I want to Split multirow resultset to single row, multicolumn resultset my table is ProfileDetail(ProfileId bigint, PropertyId bigint PropertyValue nvarchar(400)) Table data : ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.