将varchar转换为datetime错误时出错 [英] Error converting varchar to datetime error

查看:157
本文介绍了将varchar转换为datetime错误时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我不确定这是否是正确的论坛,因为 这个问题。我的appologies并想知道正确的论坛地址。


现在我在主题行中提到我非常奇怪地得到这个错误。原因是,我没有在存储的程序中传递任何日期时间参数,也没有在我的存储过程中进行任何日期时间转换。


我的存储过程是一个非常简单的插入语句,其中我有两个日期时间列,使用GetDate()填充


我从我的C#代码调用此SP,这是wcf服务的一部分。从我的代码我没有通过任何日期值(参数)到存储过程

这里的另一个奇怪的情况是,我有两个WCF服务,一个执行这个存储过程没有任何问题,另一个失败与这个错误。代码库在两种服务中都是100%相同的。这两个服务之间的唯一区别是一个
它们只托管在一个prod服务器(失败)上,另一个托管在两个prod服务器上(工作正常)。我不确定服务器配置是否必须对此做任何事情。


任何输入都会非常明显,因为我不知道我究竟会如何获得varchar到datetime转换错误当我没有尝试任何转换时。






谢谢和问候Sandeep

解决方案

我会检查以下内容:



  • 从开发人员计算机手动运行存储过程
  • 从两个WCF服务服务器手动运行存储过程
  • 运行Profiler并查看执行时为连接运行的查询有问题的.NET代码


我希望你发现这有用!如果你这样做,请在左侧投票给我们看是有帮助的。如果它回答了您的问题,请将其标记为以下答案。 :)


ok first of all, I am not sure if this is the correct forum to as  this question. My appologies and would like to know the correct forum address.

Now as mentioned in the subject line I am getting this errors very weirdly. The reason is, I am not passing any datetime parameters in the stored prodedure and also not doing any datetime conversion whatsoever in my stored procedure.

My stored procedure is a pretty simple insert statement in which I have two datetime columns which are getting populated using GetDate()

I am calling this SP from my C# code which is a part of a wcf service. From my code I AM NOT PASSING ANY DATETIME VALUES(PARAMETERS) to the stored procedure
Another weird situation over here is, I have two WCF services one executes this stored procedure without any issues and the other fails with this error. The code bases are 100% same in both the services. The only difference between these two services are one of them is hosted on only one prod server (fails) and the other one if hosted on two prod servers(works fine). I am not sure if the server configuration has to do anything with this.

Any inputs would be highly appreciable as I have no idea on how on earth I would get a varchar to datetime conversion error when I am not attempting any conversion at all.


Thanks and Regards Sandeep

解决方案

I'd check the following:

  • Run the stored procedure manually from you developer machine
  • Run the stored procedure manually from both WCF service servers
  • Run Profiler and see what queries are run for your connection when you execute the .NET code that has the issue

I hope you found this helpful! If you did, please vote it as helpful on the left. If it answered your question, please mark it as the answer below. :)


这篇关于将varchar转换为datetime错误时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆