c# DBF数据库导入导出实例

c#读取DBF数据库 (仅供参考)

private string Getstone(string content)
  {
  
   string table = @"D:/aaa/code.dbf";
   string connStr=@"Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=" + table + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO";
   OleDbConnection olecon=new OleDbConnection(connStr.ToString());
   OleDbDataAdapter sda=new OleDbDataAdapter("select * from show2003",olecon);
   
   DataSet ds=new DataSet();
   try
   {
    sda.Fill(ds);
    if(ds.Tables[0].Rows.Count==0)
    {
     sda.Dispose();
     olecon.Dispose();
     return "对不起,没有找到您查询的相关信息。";
    }
    else
    {
     sda.Dispose();
    olecon.Dispose();
     string str="";
     int i=0;
     foreach(DataRow dr in ds.Tables[0].Rows)
     {
      i++;
      str+=i.ToString()+")股票名称:"+dr[0].ToString();
      str+=",最高价:"+dr[2].ToString();
      str+=",最新价格:"+dr[1].ToString();
     }
     return str;
    }
   }
   catch
   {
    return "对不起,系统正忙请稍后再试";
   }
  }
  private DataSet GetPhone()
  {
   DataSet ds=new DataSet();
   SqlConnection scon=new SqlConnection("Server=.;DataBase=MAS;user id=sa;password=1qaz@wsx;");
   SqlDataAdapter sda=new SqlDataAdapter("select phone from tousuphone where status=1",scon);
   try
   {
    sda.Fill(ds);
   }
   catch
   {}
   sda.Dispose();
   scon.Dispose();
   return ds;
  }

你可能感兴趣的:(数据库,String,Microsoft,C#,table,dataset)