我该如何处理错误信息 [英] How do I handle error message
本文介绍了我该如何处理错误信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Visual Basic中运行我的项目时,我在调试期间收到错误消息:
参数eception未被用户代码处理
错误是指这段代码:
Sql conn = new SqlConnection(ConfigurationManager.ConnectionStrings [RegistrationConnectionString] .ConnectionString);
请帮忙
When running my project in visual basic I get the error message during debugging:
Argument eception was unhandled by user code
The error refers to this code:
Sql conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
Please help
推荐答案
您的连接字符串格式不正确。请查看以下URL以查找数据库的具体示例。
https: //www.connectionstrings.com/
此外,将来,您应该围绕连接代码和任何其他数据库访问包装try / catch。然后,当发生错误时,您应该向用户显示错误消息或记录它。
-Matt -
Your connection string is not correctly formatted for your database. Take a look at the following URL to find specific examples for your database.
https://www.connectionstrings.com/
Also, in the future, you should be wrapping a try/catch around your connection code and any other database access. Then, when an error occurs you should display the error message to the user or log it.
-Matt-
In您的 web.config 在连接字符串中使用provider一词吗?
如果使用SqlConnection,则应该使用类似的东西:
In your web.config do you use the word "provider" in your connection string?
you should use something like this if you use SqlConnection:
<add name="DBnmae" connectionstring="your connection string" providername="System.Data.sqlClient"></add>
您应该使用providerName而不是Provider。
希望这有助于
You should use "providerName" not "Provider".
Hope this helps
这篇关于我该如何处理错误信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文