c# - EntityFramework : The specified cast from a materialized 'System.String' type to the 'System.DateTime' type is not valid -


i have sp executing of sqlquery method of dbcontext.database. calling follows:

edit 1:- passing datetime now

var t = form["datetime"];//value 2013-may-08 09:30 datetime dtm; if (!datetime.tryparse(t, out dtm))//successfully parses      dtm = new datetime(2013, 05, 8, 9, 30, 0); var rtime= new sqlparameter("@rtime", dtm); var result = uow.executesp<spresult>("spresult @rtime", rtime).tolist(); 

the last line throws exception specified cast string datetime not valid.

following definition of sp.

alter proc [dbo].[spresult] (     @rtime smalldatetime --varchar(32) ) begin --other code end 

if directly execute sp in sql management studio runs without problem:

exec spresult ='2013-may-08 09:30' 

in sp string converted date time follows:

@resultat smalldatetime = cast(@rtime smalldatetime) 

what going wrong here?

what spresult take parameter? presumably datetime? in case: give datetime:

var t = datetime.now; 

or

var t = new datetime(2013,5,8,9,30,0); // 8 may 2013, 9:30am 

if error relates spresult - well, can't see hard comment: again - map sql [n][var]char(len|max) c# string, , map sql datetime c# datetime.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -