码迷,mamicode.com
首页 > 其他好文 > 详细

我的一类库

时间:2016-06-01 09:12:17      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

查询ACCESS

        /// <summary>
        /// OleDb查询数据库返回内容
        /// </summary>
        /// <param name="sql_str"></param>
        /// <returns></returns>
        protected DataTable dlBind(string sql_str)
        {
            oCon.Open();
            OleDbCommand ps = new OleDbCommand(sql_str, oCon);
            DataTable dt = new DataTable();
            dt.Load(ps.ExecuteReader());
            oCon.Close();
            return dt;

        }

打开文件并读取内容,保存字符到文件.

        /// <summary>
        ///  打开文件,反回字符串
        /// </summary>
        /// <param name="file_path">"SyntaxHighligher/com.html"</param>
        /// <returns></returns>
        private string openfiletext(string file_path)
        {
            StreamReader htmlreader = new StreamReader(file_path);
            return htmlreader.ReadToEnd();

        }
        /// <summary>
        /// 保存字符串到文件
        /// </summary>
        /// <param name="filetext"></param>
        /// <param name="file_path">"SyntaxHighligher/com.html"</param>
        private void writefiletext(string filetext,string file_path)
        {
            FileStream MyFileStream = new FileStream(file_path, FileMode.Create, FileAccess.Write);
            StreamWriter htmlWriter = new StreamWriter(MyFileStream, System.Text.Encoding.UTF8);
            htmlWriter.WriteLine(filetext);
            htmlWriter.Close();
            MyFileStream.Close();
            
        }

  

我的一类库

标签:

原文地址:http://www.cnblogs.com/praybb/p/5546858.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!