首页 新闻 会员 周边 捐助

从字符串转换日期和/或时间时,转换失败。

0
悬赏园豆:80 [已解决问题] 解决于 2015-07-21 19:30


 exec sp_executesql N'
            select CommonPoint+(OutputValue*0.01) as ''AllPoint'', 
            (OutputValue*0.01) as   ''OutputConvertValue'', AwardOrPunishment ,
                    CommonPoint ,
                    OutputValue ,
                   PR. RulesID ,
                    RulesName ,
                    RulesOrderNumber ,
                    RulesType ,
                    Unit,  isnull(Cnt,0) as ''Cnt''
             from   dbo.PointRules PR 
             left join dbo.UserRecordDetails  B on PR.RulesID = B.RulesID
             and  B.RecordID= (select  RecordID from dbo.UserRecord where
             CreateDate=''@p0'' and RecordUser=''@p1'')',
             N'@p0  datetime,@p1 nvarchar(3)',@p0='2015-07-08',@p1=N'253'
            
          
           
            
              select CommonPoint+(OutputValue*0.01) as 'AllPoint',
            (OutputValue*0.01) as  'OutputConvertValue', AwardOrPunishment ,
                    CommonPoint ,
                    OutputValue ,
                   PR. RulesID ,
                    RulesName ,
                    RulesOrderNumber ,
                    RulesType ,
                    Unit,  isnull(Cnt,0) as 'Cnt'
             from   dbo.PointRules PR 
             left join dbo.UserRecordDetails  B on PR.RulesID = B.RulesID
             and  B.RecordID= (select  RecordID from dbo.UserRecord where
             CreateDate='2015-07-08' and RecordUser='253')

 

 

 

下面的OK,上面 就报错!

pengbg的主页 pengbg | 初学一级 | 园豆:13
提问于:2015-07-08 16:23
< >
分享
最佳答案
0

不要使用双引号

收获园豆:40
| 小虾三级 |园豆:780 | 2015-07-14 23:03

Database.SqlQuery <class>(@"where RecordUser={0} and r.CreateDate={1} ",model.RecordUser,model.CreateDate)

本来  {0} {1} l两侧 都有 加上 单引号的。 去掉了 果然 ok!

pengbg | 园豆:13 (初学一级) | 2015-07-21 19:33
其他回答(1)
0

 (select  RecordID from dbo.UserRecord where 
             CreateDate=@p0 and RecordUser=@p1)试试

收获园豆:40
liaoshifa10 | 园豆:268 (菜鸟二级) | 2015-07-09 11:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册