C#如何打开DBF数据库文件
2016-02-10 12:34
435 查看
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void BindData(string table) { try { string str = table.Substring(0, table.LastIndexOf('\\')); using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + str + ";Extended Properties=dBASE IV;User ID=Admin;Password=")) { conn.Open(); string sql = @"select * from " + table.Substring(table.LastIndexOf("\\")); System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sql, conn); DataTable dt = new DataTable(); da.Fill(dt); this.dataGridView1.DataSource = dt.DefaultView; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button1_Click(object sender, EventArgs e) { this.openFileDialog1.FileName = "*.DBF"; if (openFileDialog1.ShowDialog()== DialogResult.OK) { this.BindData(this.openFileDialog1.FileName); } } } }
相关文章推荐
- [整理]MongoDB 经常使用命令总结
- 【翻译自mos文章】检查$ORACLE_HOME是否是RAC的HOME的方法以及relink RAC的Oracle binary的方法
- NoSQL 数据库的类型一览表
- oracle数据库入门sql语句
- MySql 增加字段 删除字段 修改字段名称 修改字段类型
- oracle数据库入门
- linux的oracle修改实例名SID
- 操作SQL构件的SQL生成
- 界面元素构件查询SQL的生成
- logback mybatis 打印sql语句
- Mysql服务不见的解决办法
- SpatialHadoop中空间索引系列之(八)现有空间数据库的索引方式
- sqlserver中判断表或临时表是否存在
- MySQL时间戳转换
- oracle soft 11.2.0.4 for any OS
- Redis入门很简单之八【Spring Data Redis初探】
- Redis入门很简单之七【使用Jedis实现客户端Sharding】
- Redis入门很简单之六【Jedis常见操作】
- Redis入门很简单之五【Jedis和Spring的整合】
- Redis入门很简单之四【初识Jedis】