请帮助我看一下这处程序:如何将Access(*.mdb)文件转换为其它的文件格式?
jzp12 2007-06-04 10:04:40 我想实现将其转换为如格式的文件.
*.DBF
*.MDB
*.XLS
*.DB
现在已经现实转换为*.XLS格式的文件,
但是其它的都不能,实现程序代码如下:帮我看看到底那里错了?
Public Class Form1
Inherits System.Windows.Forms.Form
Dim conn As New ADODB.Connection
Dim rsExport As New ADODB.Recordset
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Dialog1 As System.Windows.Forms.SaveFileDialog
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Protected Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.RadioButton3 = New System.Windows.Forms.RadioButton
Me.RadioButton4 = New System.Windows.Forms.RadioButton
Me.Button1 = New System.Windows.Forms.Button
Me.Dialog1 = New System.Windows.Forms.SaveFileDialog
Me.DataGrid1 = New System.Windows.Forms.DataGrid
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'RadioButton1
'
Me.RadioButton1.Location = New System.Drawing.Point(24, 32)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(120, 24)
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.Text = "Foxpro格式"
'
'RadioButton2
'
Me.RadioButton2.Location = New System.Drawing.Point(24, 96)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.TabIndex = 1
Me.RadioButton2.Text = "Access格式"
'
'RadioButton3
'
Me.RadioButton3.Location = New System.Drawing.Point(216, 32)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.Size = New System.Drawing.Size(128, 24)
Me.RadioButton3.TabIndex = 2
Me.RadioButton3.Text = "Excel格式"
'
'RadioButton4
'
Me.RadioButton4.Location = New System.Drawing.Point(216, 96)
Me.RadioButton4.Name = "RadioButton4"
Me.RadioButton4.Size = New System.Drawing.Size(120, 24)
Me.RadioButton4.TabIndex = 3
Me.RadioButton4.Text = "Paradox4.x格式"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(104, 160)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(136, 40)
Me.Button1.TabIndex = 4
Me.Button1.Text = "转换"
'
'DataGrid1
'
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(256, 128)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.TabIndex = 5
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(432, 270)
Me.Controls.Add(Me.DataGrid1)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.RadioButton4)
Me.Controls.Add(Me.RadioButton3)
Me.Controls.Add(Me.RadioButton2)
Me.Controls.Add(Me.RadioButton1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'连接数据可并打开记录集
conn.CursorLocation = ADODB.CursorLocationEnum.adUseServer
conn.Open("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\jzp.mdb;")
rsExport.Open("Select * from Customers", conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) '初始化对话框
With Dialog1
.Filter = "FoxBase/FoxPro(*.DBF)|*.DBF|Access8.0(*.MDB)|*.MDB|Excel8.0(*.XLS)|*.XLS|Paradox4.x(*.DB)|*.DB"
.Title = "导出文件为"
End With
End Sub