在运行时发生错误时,在消息框中找到行号或列号不显示 [英] Find the line no or column no display in message box when Error occurred at runtime

查看:89
本文介绍了在运行时发生错误时,在消息框中找到行号或列号不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OleDbConnection co = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;;Data Source=" + txtpathname.Text + " ;Extended Properties=Excel 8.0;
co.Open();
OleDbDataAdapter da = new OleDbDataAdapter("select MobileNo,Degree from [FristSheet$] where Degree=(select max(Degree) from [FristSheet$] where Name ='Arun')", co);





在消息框中找到no no或column no display。

当我拼错列名时 - > ' MobileNo '我给出 MbileNo ,因为在初始化那段时间发生错误我要显示某条线no和Column no



Find the line no or column no display in message box.
When i misspell the column name like -> 'MobileNo' i give as MbileNo as in initialize that time error occurred on that time i want to display the certain Line no and Column no

推荐答案

其中 Degree =( select max(Degree)来自 [FristSheet
where Degree=(select max(Degree) from [FristSheet


其中 Name = ' Arun' ,co);
where Name ='Arun')", co);





找到行号或列号没有显示在消息框。

当我拼错列名如 - >' MobileNo '我给出 MbileNo 在初始化那个时间发生错误的时候我想显示某个行号和列号



Find the line no or column no display in message box.
When i misspell the column name like -> 'MobileNo' i give as MbileNo as in initialize that time error occurred on that time i want to display the certain Line no and Column no


取决于错误发生的位置:如果你看文档 [< a href =https://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe.getfilelinenumber%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396target = _blanktitle =新窗口> ^ ]它说:

Depends where the error occurred: If you look at the documentation[^] it says:
Return Value
Type: System.Int32
The file line number, or 0 (zero) if the file line number cannot be determined.

因此,如果错误的位置没有文件信息,则为零。

GetFileColumnNumber在相同条件下返回零。



通过故意在您自己的代码中抛出错误并查看会发生什么来尝试。

So if the location of the error has no file information, you will get zero.
The GetFileColumnNumber returns zero under the same conditions.

Try it by deliberately throwing an error in your own code and see what happens.


这篇关于在运行时发生错误时,在消息框中找到行号或列号不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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