新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
如何使用VB.NET操作dbf文件
VB.NET作為一款功能比較全面的編程語言,幫助開發(fā)人員實(shí)現(xiàn)了許多復(fù)雜的功能需求。比如對各種類型文件的操作等等。下面我們就一起來看看關(guān)于VB.NET操作dbf文件的相關(guān)代碼,來對這一知識點(diǎn)進(jìn)行詳細(xì)解讀。#t#

創(chuàng)新互聯(lián)自成立以來,一直致力于為企業(yè)提供從網(wǎng)站策劃、網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、電子商務(wù)、網(wǎng)站推廣、網(wǎng)站優(yōu)化到為企業(yè)提供個性化軟件開發(fā)等基于互聯(lián)網(wǎng)的全面整合營銷服務(wù)。公司擁有豐富的網(wǎng)站建設(shè)和互聯(lián)網(wǎng)應(yīng)用系統(tǒng)開發(fā)管理經(jīng)驗(yàn)、成熟的應(yīng)用系統(tǒng)解決方案、優(yōu)秀的網(wǎng)站開發(fā)工程師團(tuán)隊(duì)及專業(yè)的網(wǎng)站設(shè)計(jì)師團(tuán)隊(duì)。
VB.NET操作dbf文件代碼示例:
- Imports System.
Data.OleDb - Imports Lion.IO.
SharpZIP.Zip - Imports Lion.IO.
SharpZIP.Checksums - Imports System.IO
- Module Module1
- Sub Main()
- 'Try
- Dim cn1 As New OleDbConnection( _
- "Provider=VFPOLEDB.1;Data
Source=C:\Temp\;")- cn1.Open()
- '-- Make some VFP data to
play with- Dim cmd1 As New OleDbCommand
( _- "Create Table TestDBF (Field1
I, Field2 C(10))", cn1)- Dim cmd2 As New OleDbCommand( _
- "Insert Into TestDBF Values
(1, '行賄)", cn1)- Dim cmd3 As New OleDbCommand( _
- "Insert Into TestDBF Values
(2, '受賄')", cn1)- cmd1.ExecuteNonQuery()
- cmd2.ExecuteNonQuery()
- cmd3.ExecuteNonQuery()
- cn1.Close()
- Dim cn2 As New OleDbConnection( _
- "Provider=VFPOLEDB.1;Data Source=C:\Temp\;")
- cn2.Open()
- Dim cmd4 As New OleDbCommand( _
- "Select * From TestDBF", cn2)
- Dim da1 As New OleDbDataAdapter(cmd4)
- Dim ds1 As New DataSet
- Dim dr1 As DataRow
- da1.Fill(ds1)
- For Each dr1 In ds1.Tables(0).Rows
- Console.WriteLine(dr1.Item(1).ToString())
- Next
- cn2.Close()
- Dim crc As New Crc32
- Dim s As New ZipOutputStream(System.
IO.File.Create("c:\temp\dbf.zip"))- s.SetLevel(6)
- Dim fs As FileFileStream = File.Open
Read("c:\temp\testdbf.dbf")- Dim b(fs.Length - 1) As Byte'c#中的
語句為byte[] b = byte[fs.Length ];要注意這點(diǎn)- fs.Read(b, 0, b.Length)
- Dim entry As ZipEntry = New ZipEntry
("c:\temp\testdbf.dbf")- entry.DateTime = DateTime.Now
- entry.Size = fs.Length
- fs.Close()
- crc.Reset()
- crc.Update(b)
- entry.Crc = crc.Value
- s.PutNextEntry(entry)
- s.Write(b, 0, b.Length)
- s.Finish()
- s.Close()
- Console.ReadLine()
- 'Catch e As Exception
- 'MsgBox(e.ToString())
- 'End Try
- End Sub
- End Module
VB.NET操作dbf文件相關(guān)操作技巧就為大家介紹到這里。
當(dāng)前名稱:如何使用VB.NET操作dbf文件
鏈接分享:http://www.fisionsoft.com.cn/article/cdssoid.html


咨詢
建站咨詢
