列名出现错误 [英] column name which getting error

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

问题描述



我想获取出现错误的列名.我正在使用try catch,但是它只给我很少的信息.我如何获得此信息?

预先感谢.

Hi,

I want to get the column name which getting error. I am using try catch but it gives me only few information. How I get this information?

Thanks in advance.

推荐答案

通常,当您导致SQL异常时非常明确:它要么给您起一个名字:
Normally, when you cause an SQL exception is is pretty explicit: it either gives you a name:
System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'description'


或至少是列参考号.
查看异常:如果使用Exception.Message,则将获得准系统版本.如果查看Exception.ToString(),您将获得更详细的(并且主要是堆栈跟踪)解释.在catch块的第一行上放置一个断点-您可以从那里开始计算.


or at a minimum a column reference number.
Look at the exception: if you use Exception.Message you will get a bare-bones version. If you look at Exception.ToString() you will get a more detailed (and mostly stack trace) explanation. Put a breakpoint on the first line of the catch block - you may be able to work it out from there.


这篇关于列名出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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