标签:
static System.Data.DataTable getOLEDB_Record(str _dbPath,str _query) { System.Data.OleDb.OleDbConnection oleDbConnection; System.Data.OleDb.OleDbCommand oleDbCommand; System.Data.OleDb.OleDbDataAdapter oleDbAdapter; System.Data.DataSet dataSet; System.Data.DataTableCollection dc; System.Data.DataTable dt; str connetionString; str dbPath = _dbPath;//= @"\\192.168.0.41\STARWATCH iTDC PRO I\iTDC-ACS.mdb"; str strAccessSelect = _query;// "SELECT top 10 * FROM qryCardEventList" ; str strFilter = ""; NoYes flag; container c; int x,y; str s; ; strAccessSelect += strFilter; connetionString = strfmt("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%1;",dbPath); try { oleDBconnection = new System.Data.OleDb.OleDbConnection(connetionString); oleDBcommand = new System.Data.OleDb.OleDbCommand(strAccessSelect,oleDBconnection); dataSet = new System.Data.DataSet(); oleDbAdapter = new System.Data.OleDb.OleDbDataAdapter(oleDbCommand); oleDBconnection.Open(); // info("Connection Open ! -OK"); oleDbAdapter.Fill(dataSet,"dutyRecord"); oleDBconnection.Close(); oleDBconnection.Dispose(); flag = true; // info("Connection Closed ! -OK"); } catch { if(!flag) { oleDBconnection.Close(); oleDBconnection.Dispose(); } throw error("Can not open connection ! "); } dc = dataSet.get_Tables(); dt = dc.get_Item(0); return dt; }
标签:
原文地址:http://www.cnblogs.com/sunsoftware/p/4288005.html