初学,如何获取类的错误信息!
问题描述:
我现在新建一个类 Mycn
类里写了个方法用来获取一个DataTable
public DataTable GetDataTable(string strsql) { conn=new SqlConnection(cnstr); DataTable dttmp = new DataTable(); SqlDataAdapter adp = new SqlDataAdapter(strsql, conn); try { adp.Fill(dttmp); } catch (Exception ex) { if (conn.State != ConnectionState.Closed()) { conn.Close(); } } finally { adp.Dispose(); return dttmp; } }