Hastable and DateTime in DataMapper

View: New views
2 Messages — Rating Filter:   Alert me  

Hastable and DateTime in DataMapper

by Teddy78 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I use DataMapper 1.6.2, SQL Server.

I have a problem when I use Hashtable of DateTime in ParameterClass :
If I use DateTime in the Hastable a get the error  :
                Input string was not in a correct format.
If I do not use the parameter date in the Hashtable, all is correct.

Have you got any ideas?
Thanks

The source code :

public List<DataDeal> GetDeals(string id, DateTime date)
{
        Hashtable map = new Hashtable();
        map.Add("id", id);
        map.Add("date", date); !! Problem with this line
        return ExecuteQueryForList<DataDeal>("SelectDeals", map) as List<DataDeal>;
}

--------

  <statements>
    <select id="SelectDeals" resultMap="DealResult" parameterClass="map">
      select code
      from TDeal
      where RefreshDate=#date# and id=#id#
    </select>
  </statements>

Re: Hastable and DateTime in DataMapper

by Michael McCurrey-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A couple of things you can try Teddy,

One, if you can use Dictionary<string,DateTime> instead of hashtable as your parameter, or
in your inline map parameter do something like this: #date,dbType=Date,type=DateTime#  (assuming your data column is a date column).

On Tue, Sep 22, 2009 at 8:44 AM, Teddy78 <teddy.fredaigues@...> wrote:

Hello,

I have a problem when I use Hashtable of DateTime in ParameterClass :
If I use DateTime in the Hastable a get the error  :
               Input string was not in a correct format.
If I do not use the parameter date in the Hashtable, all is correct.

Have you got any ideas?
Thanks

The source code :

public List<DataDeal> GetDeals(string id, DateTime date)
{
       Hashtable map = new Hashtable();
       map.Add("id", id);
       map.Add("date", date); !! Problem with this line
       return ExecuteQueryForList<DataDeal>("SelectDeals", map) as List<DataDeal>;
}

--------

 <statements>
   <select id="SelectDeals" resultMap="DealResult" parameterClass="map">
     select code
     from TDeal
     where RefreshDate=#date# and id=#id#
   </select>
 </statements>
--
View this message in context: http://www.nabble.com/Hastable-and-DateTime-in-DataMapper-tp25530794p25530794.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-cs-unsubscribe@...
For additional commands, e-mail: user-cs-help@...




--
Michael J. McCurrey
Read with me at http://www.mccurrey.com
http://chaoticmindramblings.blogspot.com/