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

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?
 
T

TJ

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/
 

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

Top