Object Must Implement IConveritble (Application Blocks error)

  • Thread starter Philip Townsend
  • Start date
P

Philip Townsend

I am using the Microsoft Application Data Block and am getting the
following error when trying to return a DataSet.

Object must implement IConvertible

Here is the code where the error occurs:

private DataSet getResults(string sd, string ed)
{
DataSet dsresults=new DataSet();
dsresults=SqlHelper.ExecuteDataset(
connection,
"prRedDecisions",
new SqlParameter("@startdate",DateTime.Parse(sd)),
new SqlParameter("@enddate",DateTime.Parse(ed))
);
return dsresults;
}

When not converting the Sql parameters to datetime, the error occurs
within the Application block itself. This tempts me to just go back to
the "old way" of doing thinkgs. Has anybody else had this problem or
know a solution? Thanks...



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
M

Mark Fitzpatrick

Whenver this has happened to me it was because of incorrect parameter
values.

What you may try to do instead is to have the application block create the
parameters for you using the parameter cache functions. You can create a
SqlParameter array called parameters to store them liek so:

SqlParameter[] parameters =
Microsoft.ApplicationBlocks.Data.SqlHelperParameterCache.GetSpParameterSet(_
ConnectionString,_SPName,false);

parameters[0].Value = Convert.ToDateTime(sd);
parameters[1].Value = Convert.ToDateTime(ed);

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top