每次总是
catch(Exception ee)
{
MesageBox.Show(ee.Message);
}
{
MesageBox.Show(ee.Message);
}
昨天晚上看书,发现了fcl里面很多Exception 的继承类,可以提供更多的一场相关信息。今天找了OleDbException ,巴适!
catch(System.Data.OleDb.OleDbException ee)
{
for (int j=0; j < ee.Errors.Count; j++)
{
MessageBox.Show("Index #" + j + " " +
"Message: " + ee.Errors[j].Message + " " +
"Native: " + ee.Errors[j].NativeError.ToString() + " " +
"Source: " + ee.Errors[j].Source + " " +
"SQL: " + ee.Errors[j].SQLState + " ");
}
}
{
for (int j=0; j < ee.Errors.Count; j++)
{
MessageBox.Show("Index #" + j + " " +
"Message: " + ee.Errors[j].Message + " " +
"Native: " + ee.Errors[j].NativeError.ToString() + " " +
"Source: " + ee.Errors[j].Source + " " +
"SQL: " + ee.Errors[j].SQLState + " ");
}
}