How to get odbcexception number
In sql we hav开发者_开发知识库e sqlexeption.numer but In odbcexeption we don't have that property,how to get the execption number?
Because more than one error can be encapsulated in an OdbcException, you need to iterate through the Errors property:
}
catch(OdbcException e)
{
for (int i=0; i < e.Errors.Count; i++)
{
Console.WriteLine("Index #{0}", i);
Console.WriteLine("Message: {0}", e.Errors[i].Message);
Console.WriteLine("NativeError: {0}", e.Errors[i].NativeError.ToString());
Console.WriteLine("Source: {0}", e.Errors[i].Source);
Console.WriteLine("SQL: {0}", e.Errors[i].SQLState);
}
}
(Note that SqlException suffers the same problem, it's just that SqlException.Number returns the first entry in the collection - it's just a wrapper for the loop above, really)
Look in the Errors collection of the OdbcException. Each OdbcError has a NativeError property.
加载中,请稍侯......
精彩评论