日期:2014-05-18 浏览次数:20809 次
/// <summary> /// 执行查询语句,返回SqlDataReader /// </summary> /// <param name="strSQL">查询语句</param> /// <returns>SqlDataReader</returns> public static OleDbDataReader ExecuteReader(string SQLString, params OleDbParameter[] cmdParms) { NewsService.FileNews.File(connectionString); OleDbConnection connection = new OleDbConnection(connectionString); OleDbCommand cmd = new OleDbCommand(); try { NewsService.FileNews.File("打开数据库链接"); connection.Open(); NewsService.FileNews.File("打开数据库链接1"); PrepareCommand(cmd, connection, null, SQLString, cmdParms); NewsService.FileNews.File("打开数据库链接2"); OleDbDataReader myReader = cmd.ExecuteReader(); NewsService.FileNews.File("打开数据库链接3"); cmd.Parameters.Clear(); return myReader; } catch (System.Data.OleDb.OleDbException e) { NewsService.FileNews.File(e.InnerException.ToString()); throw new Exception(e.Message); } }