我如何在文件中获取mysql的错误描述 [英] How can i get error descriptions of mysql in a file

查看:82
本文介绍了我如何在文件中获取mysql的错误描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在文件中获取mysql的错误描述?
我使用C#从asp.net触发插入查询,如果有一些问题,我希望执行该查询时在文件中出现这些错误或信息.

例如:-
在mysql中插入数据时显示的信息为:
!不正确的整数值:第2行的"state_id"列的"s54" !第2行的"dstatus"列的数据被截断了.

我希望在文件中包含这两个mysql信息.

How can i get error descriptions of mysql in a file??
I fire a insert query from asp.net using C# & if there is some problem i want those error or informations in a file which had occured during executing this query.

For Example:-
Information displayed in mysql while inserting data as:
! Incorrect integer value: ''s54'' for column ''state_id'' at row 2.
! Data truncated for column ''dstatus'' at row 2.

I want this two mysql information in a file.

推荐答案

您需要先使用Try,Catch,Final Block和
来捕获错误. 将错误记录到文本文件中,以确保记录StackTrace和InnerException.
You need to catch the error with a Try, Catch, Finally Block and then
log the error to a text file making sure to record the StackTrace and InnerException.


这篇关于我如何在文件中获取mysql的错误描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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