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}
}