zoukankan      html  css  js  c++  java
  • c# dbf文件读写类

     
    
     public class DbfReader     {       
    
        private string _path;      
    
        private OleDbConnection _connection;        
    
        public DbfReader(string dbfPath)         {         
    
            _path = dbfPath;           
    
           CheckFile();        
    
    }      
    
       public OleDbDataReader GetReader()       
    
      {           
    
         try           
    
        {             
    
        _connection.Open();               
    
      OleDbCommand command = new OleDbCommand("select * from [" + _path + ']', _connection);          
    
           return command.ExecuteReader(CommandBehavior.CloseConnection);        
    
         }         
    
        catch       
    
          {            
    
         return null;             
    
        throw;           
    
      }       
    
      }     
    
        public void Close()     
    
        {   
    
              _connection.Close();      
    
       }       
    
      public void CheckFile()      
    
       {          
    
       _connection = new OleDbConnection("provider=vfpoledb.1;data source=" + _path);      
    
           try        
    
       {            
    
         _connection.Open();             }             catch             {                 throw new EMException(1103);             }             finally             {                 _connection.Close();             }         }     }
    
        public class DbfWriter     {         private string _path;         public string TableName;         private string _createCommand;         private OleDbConnection _connection;         private OleDbCommand _command;         public DbfWriter(string dbfPath, string createCommand)         {             _path = dbfPath;             _createCommand = createCommand;         }         public void Open()         {             int index = _path.LastIndexOf('\');             TableName = _path.Substring(index + 1);             _connection = new OleDbConnection("provider=vfpoledb.1;data source=" + _path.Substring(0, index));             _command = new OleDbCommand("create table [" + TableName + "] " + _createCommand, _connection);             try             {                 _connection.Open();                 _command.ExecuteNonQuery();             }             catch             {                 _connection.Close();                 throw;             }         }         public void Close()         {             _connection.Close();         }         public void AppendData(string command)         {             _command.CommandText = command;             _command.ExecuteNonQuery();         }     }
  • 相关阅读:
    strcmp()比较函数和strcasecmp()和strnatcmp()
    substr()函数
    改变字符串中的字母大小写
    explode()与相反函数 implode() 和join()
    PHP nl2br() 函数
    PHP trim() 函数
    PHP的count(数组)和strlen(字符串)的内部实现
    变量处理函数库
    php中定义数组的方法
    80端口的烦恼:[3]清除NT Kernel占用80端口
  • 原文地址:https://www.cnblogs.com/Small-Life/p/3707788.html
Copyright © 2011-2022 走看看