ExecuteXmlReader not available in .net 1.1 Enterprise Library Data Access Block ??

  • Thread starter Thread starter TJ
  • Start date Start date
T

TJ

I'm trying to upgrade old code in .NET 1.0 to use the data access
application block (June 2005 version).
I'm trying to do this:

SqlCommand custCMD = new SqlCommand(sql, conn);
conn.Open();
XmlTextReader rdr = (XmlTextReader)custCMD.ExecuteXmlReader();

But guess what, there is no ExecuteXmlReader in data access app block, at
least the way I use it, I try this:

Database db = DatabaseFactory.CreateDatabase("myDatabaseName");
DBCommandWrapper dbc = db.GetSqlStringCommandWrapper(mySql);
XmlTextReader rdr = (XmlTextReader)db.ExecuteXmlReader(dbc); <----- THIS
DOESNT EXIST

There is no ExecuteXmlReader off the db object, so what I've written above
won't work.

How do I implement the ExecuteXmlReader using the data access app block in
1.0?
 
Got it.

SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
SqlCommandWrapper cmd =
(SqlCommandWrapper)db.GetStoredProcCommandWrapper(myProc);
XmlReader xmlRdr = db.ExecuteXmlReader(cmd);

Duh...because the ExecuteXmlReader was originally off the SqlCommand,
I just had to cast the Database object to a SqlDatabase object.

Here's a great article that pointed out the obvious to me:
http://msdn.microsoft.com/msdnmag/issues/05/08/DataPoints/
 
Back
Top