Unix Technical Forum

SQLXML classes deserializing.... nothing....

This is a discussion on SQLXML classes deserializing.... nothing.... within the SQL Server forums, part of the Microsoft SQL Server category; --> I am using SQLXML to pass data back and forth, well I am trying to. I try to follow ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 05:06 AM
Ralph Krausse
 
Posts: n/a
Default SQLXML classes deserializing.... nothing....

I am using SQLXML to pass data back and forth, well I am trying to. I
try to follow a tutorial but it didn't work completely. Here is my
problem. After everything executes with NO errors, my class has no
data. Here were my steps.

1. In Query Analyzer, I ran my Select statement....
Select * From Notifications Where UserID = '4192' and ParentID IS
NULL for XML AUTO
It returned...
<Notifications ID="1" UserID="4192"
CreatedWhen="2004-08-31T00:00:00" ModifiedWhen="2004-08-31T00:00:00"
ModifiedBy="1" Class="1" Name="CONSILIUMSOFT
" Enabled="1"/>

2. I saved the result in Test.xml.

3. Ran XSD on it. C:\Test>XSD TEST.XML
This MS utility wrote out the schema file, TEST.XSD

4. Ran XSD on it to create the class. C:\Test>XSD TEST.XSD /classes
/language:cs
This MS utility wrote out the CS class file, TEST.cs

5. Added the CS file to my project, create a class around it and the
code is below.

My problem is that when I put a break point where is says BR (in the
code below), pNotifications has no data in it. All the values are
NULL.

ANY ideas? I getting desperate....I should mention that I am doing
this in ASP.NET and SQL 2000 sp3

Ralph Krausse
www.consiliumsoft.com
Use the START button? Then you need CSFastRunII...
A new kind of application launcher integrated in the taskbar!
ScreenShot - http://www.consiliumsoft.com/ScreenShot.jpg


************CODE*******************

public class CNotifications
{
SqlXmlCommand objXMLCommand = new
SqlXmlCommand(ConfigurationSettings.AppSettings["XMLConnectionString"]);
Notifications pNotifications = new Notifications();

public CNotifications(int iID)
{
try
{
objXMLCommand.RootTag = "Notifications";
objXMLCommand.CommandText = @"Select * From Notifications Where
UserID = '" + iID + "' and ParentID IS NULL for XML AUTO";
objXMLCommand.CommandType = SqlXmlCommandType.Sql;
objXMLCommand.ClientSideXml = true;

XmlReader pXMLReader = objXMLCommand.ExecuteXmlReader();
XmlSerializer pSerializer = new
XmlSerializer(pNotifications.GetType());
pNotifications = (Notifications)pSerializer.Deserialize(pXMLReader) ;
pXMLReader.Close();

}
catch (SqlXmlException objEx)
{
objEx.ErrorStream.Position = 0;
string strErr = (new StreamReader(objEx.ErrorStream).ReadToEnd());
throw new Exception (strErr);
}

BP}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 05:07 AM
Erland Sommarskog
 
Posts: n/a
Default Re: SQLXML classes deserializing.... nothing....

Ralph Krausse (gordingin@consiliumsoft.com) writes:
> My problem is that when I put a break point where is says BR (in the
> code below), pNotifications has no data in it. All the values are
> NULL.


XML is not my best game, but I can't see that you are actually reading
from your SqlXmlReader.

You are probably better off in asking in a group like
microsoft.public.dotnet.framework.adonet.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:26 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com