.NETGURU
best way to get a single piece of data out of a DataSet?
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngdata' list.


Francesco Sanfilippo
I have a set of 10 DataTables in a DataSet, and I need to get one column out
of one row out of one table in the DataSet.

I have tried the code below but I get an error. Any help?

TIA, Francesco

Error: Object reference not set to an instance of an object, line 235

Code:

234: DataRow dr;
235: dr = newVisitor.MemberData.Tables["PersonAddress"].Rows[0];
236: Session["test"] = dr["profile_name"].ToString();

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

Reply to this message...
 
    
Mark Bruce
Break it down into something like this to see what is null...

MemberDataType md = newVisitor.MemberData;
DataTable dt = md.Tables["PersonAddress"];
DataRow dr = dt.Rows[0];
dr = Session["test"] = dr["profile_name"].ToString();

My guess, from just looking at the code is:
MemberData is null or
PersonAddress table doesnt exist or
PersonAddress table does not contain any rows.

HTH!
Mark
--- Francesco Sanfilippo <Click here to reveal e-mail address> wrote:
[Original message clipped]

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

Reply to this message...
 
    
Francesco Sanfilippo
I found the problem. Nothing to do with the code, more to do with an issue
I still haven't resolved. How to get DataTables named the way I want them
when filling a DataSet from a DataAdapter which is filled by a SQL stored
procedure that returns multiple result sets from complex joins? By default,
the tables are named like this: Table, Table1, Table2, Table3, etc. It
took me forever to realize that the first table was named Table instead of
something more obvious like Table0 or Table1. Do I need to create the
schema for the DataTables as I construct the DataSet, so they are named the
way I want?

Francesco

[Original message clipped]

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

Reply to this message...
 
    
Mark Feinholz
How about just using ordinal constants and referring to the DataTables
collection that way?

-----Original Message-----
From: Francesco Sanfilippo [mailto:Click here to reveal e-mail address]
Sent: Wednesday, June 05, 2002 11:22 AM
To: aspngdata
Subject: [aspngdata] Re: best way to get a single piece of data out of a
DataSet?

I found the problem. Nothing to do with the code, more to do with an
issue
I still haven't resolved. How to get DataTables named the way I want
them
when filling a DataSet from a DataAdapter which is filled by a SQL
stored
procedure that returns multiple result sets from complex joins? By
default,
the tables are named like this: Table, Table1, Table2, Table3, etc. It

took me forever to realize that the first table was named Table instead
of
something more obvious like Table0 or Table1. Do I need to create the
schema for the DataTables as I construct the DataSet, so they are named
the
way I want?

Francesco

[Original message clipped]

_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com

| [aspngdata] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Francesco Sanfilippo
What I did was rename the tables after they were created, so I can call them
intelligently from other code. Works great now.

FS

[Original message clipped]

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx

Reply to this message...
 
    
Andy Smith
If I have a Strongly Typed DataSet bound to a single-record style form, =
Is there any easy way to clone the current record into a new record?

__
Andy Smith
Chief Code Monkey
=20

Reply to this message...
 
    
Michael Pizzo
In this release, a DataRow always exists inside of a DataTable; you
can't have a stand-alone DataRow. However, if you want to copy the a
DataRow into a new table, you can DataTable.ImportRow() which copies the
DataRow, its original and current values, and row state.

HTH,

-Mike
-----Original Message-----
From: Andy Smith [mailto:Click here to reveal e-mail address]=20
Sent: Monday, June 10, 2002 3:59 PM
To: aspngdata
Subject: [aspngdata] Re: best way to get a single piece of data out of a
DataSet?

If I have a Strongly Typed DataSet bound to a single-record style form,
Is there any easy way to clone the current record into a new record?

__
Andy Smith
Chief Code Monkey
=20

| [aspngdata] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngdata.asp =3D JOIN/QUIT
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
 
System.Data.Common.DataAdapter
System.Data.DataRow
System.Data.DataSet
System.Data.DataTable




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification