您的位置:首页 > 编程语言

列车时刻查询系统(北大青鸟大二寒假作业) 源代码(七)

2008-01-23 22:05 344 查看
导入数据类,主要包括导入XML数据


using System;


using System.Data;


using System.Windows.Forms;


namespace train




...{




/**//// <summary>


/// ImportData :导入数据


/// </summary>


public class ImportData




...{


private DataSet ds;


private DataTable table;


public ImportData()




...{


ds=new DataSet();


table=new DataTable();


}




/**//// <summary>


/// 从XML文件导入数据


/// </summary>


/// <returns>返回包含数据的DataTable</returns>


public DataTable ImportDataFromXml()




...{


OpenFileDialog dialog=new OpenFileDialog();


dialog.Filter="XML文件|*.xml";


dialog.ShowDialog();


string path=dialog.FileName;


if(path.Length==0)




...{


return null;


}


try




...{


ds.ReadXml(@path,XmlReadMode.Auto);


return ds.Tables[0];


}


catch(Exception e)




...{


Console.WriteLine(e.Message);


return null;


}


}




}


}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐