为什么我从字符串转换数据和/或时间时出现错误“转换失败”? [英] Why Am I Getting The Error "Conversion Failed When Converting Data And/Or Time From Character String"?

查看:224
本文介绍了为什么我从字符串转换数据和/或时间时出现错误“转换失败”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在客户端的机器上部署了一个应用程序

数据库也已正确配置。

但是当我试图插入任何值时,我得到上述声明即使我没有插入任何日期或时间值也会出错?

为什么会发生这种情况以及如何解决此错误?

请帮助

i have deployed an application on client's machine
the database has also been configured correctly.
but when i am trying to insert any value I am getting the above stated error even when I am not inserting any date or time value?
why is it happening and how to resolve this error?
Please help

推荐答案

如果即使您没有在数据库中插入任何内容也会出现错误,那么只剩下两个选项:



1)这是在非INSERT-Sql-Statement中发生的错误 - 可能是您正在尝试进行转换的SELECT



2)它没有与数据库有关,并发生在你的代码中的其他地方。



根据你提供的信息,我们无法弄清楚这个错误究竟发生在哪里,也不知道我们可以告诉你如何解决它。 *



但是这会让你更接近它:在try-catch-block中捕获异常如果你还没有这样做。将异常的堆栈跟踪转储到控制台(如果它是控制台应用程序)或将其写入文件。分析堆栈跟踪 - 它将显示错误发生的位置。如果您无法理解,请将堆栈跟踪添加到您的问题中并发表评论。



* (编辑):除了显而易见的(?) - 您正在尝试将字符串转换为日期/时间值,但它不起作用,因为字符串没有适当的格式。
If the error occurs even when you're not inserting anything into the database then there are only two options left:

1) It's an error that's occurring in a non-INSERT-Sql-Statement - possibly a SELECT in which you're trying to do a conversion

2) It doesn't have anything to do with the database and occurs somewhere else in your code.

From what information you provided, we can't figure out where exactly this error is occurring nor can we tell you how exactly to resolve it. *

But this will get you closer to it: Catch the exception in a try-catch-block if you're not already doing that. Dump the stacktrace of the exception to the console (if it's a console app) or write it into a file. Analyze the stacktrace - it will show you where the error is occurring. If you can't figure it out then, add the stacktrace to your question and leave a comment please.

* (edit) : Apart from the obvious (?) - that you're trying to convert a string into a Date / Time value and it doesn't work because the string doesn't have an appropriate format.


这篇关于为什么我从字符串转换数据和/或时间时出现错误“转换失败”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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