Chris Hammond is
a father, husband, developer, geek, car guy. The Director of Training for DotNetNuke Corporation. To learn more about Chris check out the about me page.
LIVESTRONG Challenge Davis

I use Strava to track my bicycle rides. Below you can see my recent activity.

 

Tags
  1. 12 items are tagged with .net
  2. 58 items are tagged with asp.net
  3. 47 items are tagged with Autocross
  4. 12 items are tagged with Baby
  5. 39 items are tagged with Boston Red Sox
  6. 21 items are tagged with California
  7. 15 items are tagged with Car
  8. 29 items are tagged with Community Server
  9. 14 items are tagged with communityserver
  10. 17 items are tagged with Corvette
  11. 26 items are tagged with daily tips
  12. 93 items are tagged with Development
  13. 180 items are tagged with DotNetNuke
  14. 25 items are tagged with DotNetNuke Development
  15. 11 items are tagged with DotNetNuke Tips
  16. 12 items are tagged with DotNetNuke Training
  17. 12 items are tagged with Electric
  18. 12 items are tagged with Energy
  19. 25 items are tagged with Family
  20. 73 items are tagged with Fitness
  21. 117 items are tagged with Friends
  22. 44 items are tagged with Games
  23. 32 items are tagged with general Software Development
  24. 13 items are tagged with Green
  25. 22 items are tagged with HDTV
  26. 18 items are tagged with Health
  27. 13 items are tagged with Leaf
  28. 381 items are tagged with Life News
  29. 12 items are tagged with Microsoft
  30. 39 items are tagged with Music
  31. 14 items are tagged with Nissan
  32. 13 items are tagged with Nissan Leaf
  33. 88 items are tagged with Photography
  34. 18 items are tagged with Photos
  35. 89 items are tagged with Pictures
  36. 108 items are tagged with Places to See
  37. 20 items are tagged with Project 240Z
  38. 12 items are tagged with Project 350Z
  39. 21 items are tagged with Red Sox
  40. 19 items are tagged with Red Sox in St. Louis
  41. 15 items are tagged with SCCA
  42. 418 items are tagged with SEO
  43. 203 items are tagged with Site News
  44. 33 items are tagged with St. Louis
  45. 275 items are tagged with Technology
  46. 41 items are tagged with Travel
  47. 17 items are tagged with Vista
  48. 16 items are tagged with Weblog
  49. 16 items are tagged with Xbox360
  50. 12 items are tagged with Zune

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

Last Updated Wednesday, January 23, 2008 4:50 PM


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

 

Recent Comments
Thanks for the info... I was having the same problem and it was driving me crazy! :)
Posted By: Anonymous Poster on Sunday, March 27, 2005 12:40 AM
Thanks that worked perfect (VB.NET)
Unfortunately it seems to make the data access code a lot more complex.

Seems it would almost be better to NOT use the Enterprise Library in this situation.


Posted By: Anonymous Poster on Thursday, May 12, 2005 12:03 PM
I think it's a bug. ----------------------------------------- haoder@msn.com
Posted By: Anonymous on Tuesday, January 10, 2006 8:36 AM
Instead of SqlDataReader, use IDataReader for your 'dr'. You won't have to cast it and it should work perfectly. Strangely enough though, I use the exact same code in two different application. One works fine and the other is throwing the same exception you're getting.
Posted By: Anonymous on Monday, February 13, 2006 6:08 PM
here's the working solution: http://forums.asp.net/p/1560116/3850817.aspx
Posted By: mark ern on Wednesday, August 11, 2010 11:28 PM