社区
C#
帖子详情
datagridview里的数据导出为dbf文件!!
堆代码的爱因斯坦
2021-02-25 09:55:28
datagridview里的数据如何导出为dbf文件!!
已安装VFPOLEDBSetup.msi
...全文
277
7
打赏
收藏
datagridview里的数据导出为dbf文件!!
datagridview里的数据如何导出为dbf文件!! 已安装VFPOLEDBSetup.msi
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
xuzuning
2021-03-30
打赏
举报
回复
用 OleDbConnection 通过数据源驱动 VFPOLEDB.1 来实现 dbf文件 的格式很简单,你也可以直接文件操作生成
良朋
2021-03-30
打赏
举报
回复
楼主还在用VFP吗?
shawn_yang
2021-03-30
打赏
举报
回复
你搜一下vfp的api,都是微软出的datatable转dbf应该有接口
堆代码的爱因斯坦
2021-03-02
打赏
举报
回复
我顶!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
cuiwei16236
2021-02-26
打赏
举报
回复
可以试试FastDbf,https://github.com/SocialExplorer/FastDBF
瓜皮弟子头很铁
2021-02-25
打赏
举报
回复
https://blog.csdn.net/dujiajiyiyi/article/details/53841398,差不多的
堆代码的爱因斯坦
2021-02-25
打赏
举报
回复
csdn要亡了 吗?没人啊
c#
DBF
数据
库导入
导出
实例
c#
DBF
数据
库导入
导出
实例 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.Odbc; using System.Data.SqlClient; namespace
Dbf
Example { public partial class Form1 : Form { System.Data.Odbc.OdbcConnection conn; public Form1() { InitializeComponent(); } //
导出
数据
private void btnOut_Click(object sender, EventArgs e) { string connect = "Driver={Microsoft Visual FoxPro Driver};SourceType=
DBF
;SourceDB=c:\\; "; OdbcConnection myconn = new OdbcConnection(connect); string sqlt ="CREATE TABLE aa.
DBF
(cc int(10))"; myconn.Open(); OdbcCommand olec = new OdbcCommand(sqlt, myconn); try { int i = olec.ExecuteNonQuery(); MessageBox.Show("'" + i + "'success"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { olec.Dispose(); myconn.Close(); } //string ole_connstring = @"Provider=microsoft.jet.oledb.5.0;Data Source=D:\;"; //System.Data.OleDb.OleDbConnection ole_conn = new System.Data.OleDb.OleDbConnection(ole_connstring); //try //{ // ole_conn.Open(); // System.Data.OleDb.OleDbCommand cmd1 = new System.Data.OleDb.OleDbCommand // ("Create Table TestTable (Field1 int, Field2 char(10),Field float(10,2))", // ole_conn); // System.Data.OleDb.OleDbCommand cmd2 = new System.Data.OleDb.OleDbCommand // ("Insert Into TestTable values (1,'Hello3',520.20)", ole_conn); // System.Data.OleDb.OleDbCommand cmd3 = new System.Data.OleDb.OleDbCommand // ("Insert Into TestTable values (2,'Hello4',18076.60)", ole_conn); // cmd1.ExecuteNonQuery(); // cmd2.ExecuteNonQuery(); // cmd3.ExecuteNonQuery(); //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} //finally //{ // ole_conn.Close(); //} } //导入
数据
private void btnIn_Click(object sender, EventArgs e) { } private void Form1_Load(object sender, EventArgs e) { Bind(); } private void Bind() { try { conn = new System.Data.Odbc.OdbcConnection(); string table = @"C:\测试例子\
Dbf
\prepur.
dbf
"; string connStr = @"Driver={Microsoft Visual FoxPro Driver};SourceType=
DBF
;SourceDB=" + table + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO"; conn.ConnectionString = connStr; conn.Open(); string sql = @"select * from " + table; OdbcDataAdapter da = new OdbcDataAdapter(sql, conn); DataTable dt = new DataTable(); da.Fill(dt); this.
dataGridView
1.DataSource = dt.DefaultView; //MessageBox.Show(dt.Rows[0][0].ToString()); } catch { } finally { conn.Close(); } } private void
dataGridView
1_CellContentClick(object sender,
DataGridView
CellEventArgs e) { try { conn = new System.Data.Odbc.OdbcConnection(); string table = @"C:\测试例子\
Dbf
\table1.
dbf
"; string connStr = @"Driver={Microsoft Visual FoxPro Driver};SourceType=
DBF
;SourceDB=" + table + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO"; conn.ConnectionString = connStr; conn.Open(); string id =
dataGridView
1.Rows[e.RowIndex].Cells[0].Value.ToString(); string sql = @"select * from " + table + " where id='" + id + "'"; OdbcDataAdapter da = new OdbcDataAdapter(sql, conn); DataTable dt = new DataTable(); da.Fill(dt); txtId.Text = id; txtName.Text = dt.Rows[0]["name"].ToString(); txtAddress.Text = dt.Rows[0]["address"].ToString(); } catch { } finally { conn.Close(); } } private void Add() { conn = new System.Data.Odbc.OdbcConnection(); string table = @"C:\temp\
Dbf
\table1.
dbf
"; string connStr = @"Driver={Microsoft Visual FoxPro Driver};SourceType=
DBF
;SourceDB=" + table + ";Exclusive=No;NULL=NO;Collate=Machine;BACKGROUNDFETCH=NO;DELETED=NO"; conn.ConnectionString = connStr; conn.Open(); OdbcCommand cmd = new OdbcCommand(); cmd.Connection = conn; string sql = "insert into " + table + " values('" + txtId.Text + "','" + txtName.Text + "','" + txtAddress.Text + "')"; cmd.CommandText = sql; cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); Bind(); } private void btnTOSQL_Click(object sender, EventArgs e) { try { string sql = "Insert Into
dbf
tosql select * From openrowset('MSDASQL','Driver=Microsoft Visual FoxPro Driver;SourceType=
DBF
;SourceDB=C:\\temp\\
Dbf
','select * from table1.
dbf
')"; SqlConnection con = new SqlConnection("server=.;database=labelprint;uid=sa;pwd=sa"); con.Open(); SqlCommand cmd = new SqlCommand(sql, con); cmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
C#窗体excel与
dbf
的导入
导出
** 网上能搜到的比较零碎,整理帖 ** 导入比较简单代码如下 EXCEL private void button2_Click(object sender, EventArgs e) { string fileName = “”; fileName = this.textBox1.Text; if (this.textBox1.Text != “”) { try { string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = "
【转】c#
DBF
数据
库导入
导出
实例
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.Odbc;using System.Data.S...
DataGrid
导出
到 Excel 的帮助类
DataGrid
导出
到 Excel 的帮助类 //===============================================================================////从DataGrid或
数据
源中
导出
数据
到Excel并提示下载的帮助类。////Author: Neil Chen(木野狐)/...
C#将SQL
数据
库中
数据
导入Excel中,并将Excel中反导入SQL
数据
库中
实际的开发中,我们会经常遇到
数据
的转化的需要,将Excel中的
数据
转入到SQL中,或将SQL在
数据
库表中的
数据
导入到Excel中。代码如下: Code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing...
C#
110,545
社区成员
642,580
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章