您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關(guān)VB.NET中怎么操作dbf文件,小編覺(jué)得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說(shuō),跟著小編一起來(lái)看看吧。
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 withDim 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#中的
語(yǔ)句為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文件,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見(jiàn)到或用到的。希望你能通過(guò)這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。