try
{
.....
}
catch(Exception e)
{
}about Exception with C# look here
here maybe can help you:
http://www.mantrotech.com/technology/csharp/article_csharp_exception_1.asp
{
.....
}
catch(Exception e)
{
}about Exception with C# look here
here maybe can help you:
http://www.mantrotech.com/technology/csharp/article_csharp_exception_1.asp
ms-help://MS.VSCC/MS.MSDNVS.2052/cpref/html/frlrfsystemdatasqlclientsqlexceptionclasstopic.htm
相对应的属性名字几乎没有变化.你可以简单的参考这个例子:public void ThrowSqlException()
{
string myConnString = "user id=sa;password=;database=northwind;server=badserver";
SqlConnection myConnection = new SqlConnection(myConnString);
try
{
myConnection.Open();
}
catch (SqlException e)
{
SqlErrorCollection myErrors = e.Errors;
Console.WriteLine("Class: {1}", e.Class);
Console.WriteLine("Error #{1}: {2} on line {3}.", e.Number, e.Message, e.LineNumber);
Console.WriteLine("Error reported by {1} while connected to {2}", e.Source, e.Server);
Console.WriteLine("Neither record was written to database.");
Console.WriteLine("Errors collection contains:"); for (int i=0; i < myErrors.Errors.Count; i++)
{
Console.WriteLine("Class: {1}", myErrors[i].Class);
Console.WriteLine("Error #{1}: {2} on line {3}.", myErrors[i].Number, myErrors[i].Message, myErrors[i].LineNumber);
Console.WriteLine("Error reported by {1} while connected to {2}", myErrors[i].Source, myErrors[i].Server);
}
}
>>如何实现raise效果?
使用throw抛出.
较好像VB里,系统自动捕获异常“on error goto errorHandle”
然后在errorHandle:里向上层返回错误信息
在调用组建的catch就会自动捕获
这样还可以自定义Exception
把错误信息直接现实给客户
你在Catch以后进行处理就可以了.
能举一个例子说说什么是"向上层返回错误信息".