· Chris Hammond
Last Updated

Microsoft Enterprise Library Data Access Application Blocks Execute Reader (Object must implement IConvertible)

Learn how to successfully use the MS Enterprise Library Data Access Application Blocks for executing readers with this helpful code snippet and resources.

Learn how to successfully use the MS Enterprise Library Data Access Application Blocks for executing readers with this helpful code snippet and resources.

I've been trying to get the MS Enterprise Library Data Access Applications Blocks working this morning. Yesterday I got the library setup and running. I started to implement the DAAB so that I could call a stored procedure, passing in a parameter, and retrieving a datareader that I could fill into a class. But I was having some horrible problems trying to get the stored procedure to run and fill the datareader using the DAAB.

I was continually getting the error “Object must implement IConvertible“ and was unable to figure out why this was.

sqlCommand = "spCMS_CustomerLostPasswordEmailAddress";
//parameters
SqlParameter [] parms = {new SqlParameter("@EmailAddress", SqlDbType.VarChar, 50)};
parms[0].Value= identifier;
DBCommandWrapper dbcw = db.GetStoredProcCommandWrapper(sqlCommand,parms);
SqlDataReader dr = db.ExecuteReader(dbcw);

It would return the error while trying to perform the ExecuteReader command.

In order to get the code to successfully function I had to do the following

DBCommandWrapper dbcw = db.GetStoredProcCommandWrapper("spCMS_CustomerLostPasswordEmailAddress");
dbcw.AddInParameter("@EmailAddress", DbType.String, identifier);
SqlDataReader dr = (SqlDataReader)db.ExecuteReader(dbcw);

So if you're looking to use execute reader with the Microsoft Enterprise Library Data Access Application Blocks I hope the above code helps!

Also, some resources I used to figure all of this out!

Enterprise Library / Data Access Application Block Follow-up
An Introduction to the Microsoft Enterprise Library by Scott Mitchell

 

Back to Blog

Related Posts

View All Posts »
Interesting Ajax Article to read

Interesting Ajax Article to read

Learn more about the basics of AJAX with this informative guide from IBM Developer. Bookmark the link for future reference! #ajax #webdevelopment #IBM

CarBlocks.com

CarBlocks.com

Enhance search indexing for CarBlocks.com with these quick tips to boost visibility and reach your target audience effectively.

Excellent Programmer!

Excellent Programmer!

Looking for an excellent programmer with mad skills? Look no further! Find out more about our exceptional developer here. #programming #techtalent