All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
.NET,2.0,中对配置文件的读写_.net资料_编程技术
浅谈,DotNet,保护中字符串加密的技术_.net资料_编程技术
VC#2005快速入门之复合赋值操作符_[Asp.Net教程]
解析SQL Server 2008中的新语句:MERGE_[SQL Server教程]
在.net中创建使用全球唯一标识符_[Asp.Net教程]
C#基础学习,——,异步编程篇_.net资料_编程技术
关于phpwind,5.01-5.3,0day的分析文章_php资料_编程技术
《Effective,C#》:值类型和引用类型_.net资料_编程技术
详细介绍:Apache+PHP+MySQL配置攻略_php资料_编程技术
成为PHP高手,学会懒惰地用PHP编程_php资料_编程技术
Reading number is top 10 pictures
The money of more than 100 countries and regions4
奇趣的世界记录2
Take you to walk into the most true north Korea rural1
China's programmers are live what kind, had a look at will know that
程序员的悲哀
NeedWallpaper12
Magnificent cloud1
俞敏洪在清华终于说了实话
Play for Free show breast in a world of ice and snow
The Soviet union swimsuit exposure in the 70 year1
Download software ranking
Tram sex maniac 2 (H) rar bag2
Boxer's Top ten classic battle8
C#高级编程(第4版)
Visual C++界面编程技术
1400篇各类破解文章
Tram sex maniac 2 (H) rar bag10
C++编程教程第三版
Unix video tutorial17
matrix2
Tram sex maniac 2 (H) rar bag14
aaa published in(发表于) 2013/12/13 9:44:06 Edit(编辑)
用C#对DBF数据库的操作_.net资料_编程技术

用C#对DBF数据库的操作_.net资料_编程技术

用C#对DBF数据库的操作_.net资料_编程技术-你的首页-uuhomepage.com

现在大部分C#连接数据库都会是sql server 。但对一些旧的数据库文件的连接和操作就不太熟了。
今天就有这个问题,要对FOXPRO生成的DBF文件数据库进行操作。
我在CSDN上查了很久,大部分有问题都没很好地回复到这些操作上的问题。
经过我的实验,用ODBC来连接它就可以了。
下面是所用的代码。
都很简单,就是格式上要注意。和用开的查询语句会有很大不同。
protected void Page_Load(object sender, EventArgs e)
{
System.Data.Odbc.OdbcConnection conn = new System.Data.Odbc.OdbcConnection();
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";


conn.ConnectionString = connStr;
conn.Open();


OdbcCommand cmd = new OdbcCommand();
cmd.Connection = conn;
string sql = "update " + table + " set other='2',rate=1.014 ";
cmd.CommandText = sql;
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();


sql = @"select * from " + table;
OdbcDataAdapter da = new OdbcDataAdapter(sql,conn);
DataTable dt = new DataTable();
da.Fill(dt);
this.GridView1.DataSource = dt.DefaultView;
this.GridView1.DataBind();


}
注意点:1 连接串的格式。2 所对应的表名必须要有路径。






添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.