Dynamics AX Read OLEDB
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; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。