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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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} } |
| ||||
| 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 |