.NET 里面访问DBF文件

string strConn ="Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;Exclusive=Yes;SourceDB="+"c:/";
    OdbcConnection conn = new OdbcConnection(strConn);
    OdbcDataAdapter oda = new OdbcDataAdapter();
    OdbcCommand mycomm;
    conn.Open();
    string sql = " insert into ["+this.FileName.ToString()+"]([zkzh],[xm],[sfzh],[ksdd],[kmmc],[zt]";
    for(int i=0;i<ds.Tables[0].Rows.Count;i++)
    {
     sql+=","+"["+ds.Tables[0].Rows[i][0].ToString().Trim()+"]";
    }
    sql+=",jzf,jf ) values ( '"+this.listView1.Items[j].SubItems[0].Text.ToString().Trim()+"'";
    for(int i=1;i<this.listView1.Columns.Count;i++)
    {
     sql+=",'"+this.listView1.Items[j].SubItems[i].Text.Trim()+"'";
    }
    sql+=" )";
    mycomm=new OdbcCommand(sql,conn);
    mycomm.ExecuteNonQuery();
    conn.Close(); 

你可能感兴趣的:(.NET 里面访问DBF文件)