1
什么是比try/catch包装更好的方式来验证TableAdapter上的连接是否已打开或将成功打开?验证TableAdapter连接字符串是否成功打开?
public class MyItemParser
{
private myTableAdapter fa;
public FacultyParser()
{
this.fa = new facultyTableAdapter();
}
public bool HasValidConnection()
{
try
{
this.fa.Connection.Open();
}
catch(exception e)
{
return false;
}
return true;
}
public void FillList(IList<myItem> list)
{
foreach (var row in this.fa.GetData())
/**** DoSomething ****/
}
}