Object Must Implement IConveritble (Application Blocks error)

  • Thread starter Thread starter Philip Townsend
  • Start date 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!
 
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
 
Back
Top