Reading xml from database

M

Mukesh

HI all

I am storing user info in database. for this i m using varchar(for
storing name , email , password etc.) and xml(UserDetail info ) datatypes.

dbo.User
........................
USEREMAIL VARCHAR PK
USERNAME VARCHAR
USERPWD VARCHAR
USERDETAILS XML




for retriving data i m using
this query "Select * from user where [email protected]"
in dataset dsCredentialData


string Name = dsCredentialData.Tables[0].Rows[0]["USERNAME"].tostring();
string

PrimaryEmail=dsCredentialData.Tables[0].Rows[0]["USEREMAIL"].tostring();
string UserPwd =dsCredentialData.Tables[0].Rows[0]["userpwd"].tostring();
Xml UserDetails= new Xml();

UserDetails.Document.LoadXml(dsCredentialData.Tables[0].Rows[0]["XmlTxt"].tostring());


after doing this i m getting this error

"Object reference not set to an instance of an object. "

PLease tell me how i can use this xml Userdetails As xml object without
saving it to disk


Thanks in advance..
 
W

Walter Wang [MSFT]

Hi Mukesh,

The error "Object reference not set to an instance of an object" probably
because the query result is empty. Try to debug your code and watch which
object is null;or you could create some intermediate variables:

DataTable dt = dsCredentialData.Tables[0];
DataRow dr = dt.Rows[0];
object dc = dr["XmlTxt"];

XmlDocument UserDetails = new XmlDocument();
UserDetails.LoadXml(dc.ToString());

And see which statement caused the NullReference exception.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Walter Wang [MSFT]

Hi Mukesh,

I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.

Have a great day!


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top